@@ -293,6 +293,14 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
293293 debug ! ( "looking for associated item named {} for item {:?}" , item_name, did) ;
294294 let ty = cx. tcx . type_of ( did) ;
295295 // Checks if item_name belongs to `impl SomeItem`
296+ // `def_id` should be a trait
297+ let associated_items_for_def_id = |tcx : ty:: TyCtxt < ' _ > , def_id : DefId | -> Vec < _ > {
298+ tcx. associated_items ( def_id)
299+ . filter_by_name ( tcx, Ident :: with_dummy_span ( item_name) , def_id)
300+ . map ( |assoc| ( assoc. def_id , assoc. kind ) )
301+ // TODO: this collect seems a shame
302+ . collect ( )
303+ } ;
296304 let impls = crate :: clean:: get_auto_trait_and_blanket_impls ( cx, ty, did) ;
297305 let candidates: Vec < _ > = impls
298306 . flat_map ( |impl_outer| {
@@ -316,7 +324,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
316324 )
317325 } )
318326 // TODO: this collect seems a shame
319- . collect ( )
327+ . collect :: < Vec < _ > > ( )
320328 } else {
321329 // These are provided methods or default types:
322330 // ```
@@ -326,17 +334,14 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
326334 // }
327335 // ```
328336 // TODO: this is wrong, it should look at the trait, not the impl
329- cx. tcx . associated_items ( impl_outer. def_id )
330- . filter_by_name ( cx. tcx , Ident :: with_dummy_span ( item_name) , impl_outer. def_id )
331- . map ( |assoc| ( assoc. def_id , assoc. kind ) )
332- // TODO: this collect seems a shame
333- . collect :: < Vec < _ > > ( )
337+ associated_items_for_def_id ( cx. tcx , impl_outer. def_id )
334338 }
335339 }
336340 _ => panic ! ( "get_impls returned something that wasn't an impl" ) ,
337341 }
338342 } )
339- . chain ( cx. tcx . all_impls ( ) )
343+ . chain ( cx. tcx . all_impls ( did) . flat_map ( |impl_| associated_items_for_def_id ( cx. tcx , impl_) ) )
344+ //.chain(cx.tcx.all_local_trait_impls(did).flat_map(|impl_| associated_items_for_def_id(cx.tcx, impl_)))
340345 . collect ( ) ;
341346 if candidates. len ( ) > 1 {
342347 let candidates = candidates. into_iter ( )
0 commit comments