@@ -65,24 +65,12 @@ impl<'tcx> LateLintPass<'tcx> for SameNameMethod {
65
65
} ) = & item. kind
66
66
{
67
67
if let TyKind :: Path ( QPath :: Resolved ( _, Path { res, .. } ) ) = self_ty. kind {
68
- for impl_item_ref in ( * items)
69
- . iter ( )
70
- . filter ( |impl_item_ref| matches ! ( impl_item_ref. kind, rustc_hir:: AssocItemKind :: Fn { .. } ) )
71
- {
72
- let method_name = impl_item_ref. ident . as_str ( ) ;
73
- match of_trait {
74
- Some ( _trait_ref) => {
75
- // FIXME: try to collect default methods in trait.
76
- // but `rustc_middle::ty::assoc::AssocItems::items` is not public
77
- // if let Some(node)=cx.tcx.hir().find(trait_ref.hir_ref_id){
78
- // if let Node::TraitRef(TraitRef{path,..})=node{
79
- // if let Res::Def(DefKind::Trait,did)=path.res{
80
- // items is private
81
- // cx.tcx.associated_items(did).items.iter().filter(|_k,v|matches!(v,AssocKind::
82
- // Fn)). map(|(k,_v)|k).collect(); }
83
- // }
84
- // }
85
-
68
+ match of_trait {
69
+ Some ( _trait_ref) => {
70
+ for impl_item_ref in ( * items) . iter ( ) . filter ( |impl_item_ref| {
71
+ matches ! ( impl_item_ref. kind, rustc_hir:: AssocItemKind :: Fn { .. } )
72
+ } ) {
73
+ let method_name = impl_item_ref. ident . as_str ( ) ;
86
74
let trait_span = impl_item_ref. span ;
87
75
if let Some ( s) = mp. get_mut ( res) {
88
76
if let Some ( impl_span) = s. impl_methods . get ( & method_name) {
@@ -110,8 +98,13 @@ impl<'tcx> LateLintPass<'tcx> for SameNameMethod {
110
98
} ,
111
99
) ;
112
100
}
113
- } ,
114
- None => {
101
+ }
102
+ } ,
103
+ None => {
104
+ for impl_item_ref in ( * items) . iter ( ) . filter ( |impl_item_ref| {
105
+ matches ! ( impl_item_ref. kind, rustc_hir:: AssocItemKind :: Fn { .. } )
106
+ } ) {
107
+ let method_name = impl_item_ref. ident . as_str ( ) ;
115
108
let impl_span = impl_item_ref. span ;
116
109
if let Some ( s) = mp. get_mut ( res) {
117
110
if let Some ( trait_spans) = s. trait_methods . get ( & method_name) {
@@ -136,8 +129,8 @@ impl<'tcx> LateLintPass<'tcx> for SameNameMethod {
136
129
} ,
137
130
) ;
138
131
}
139
- } ,
140
- }
132
+ }
133
+ } ,
141
134
}
142
135
}
143
136
}
0 commit comments