@@ -293,6 +293,14 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
293
293
debug ! ( "looking for associated item named {} for item {:?}" , item_name, did) ;
294
294
let ty = cx. tcx . type_of ( did) ;
295
295
// 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
+ } ;
296
304
let impls = crate :: clean:: get_auto_trait_and_blanket_impls ( cx, ty, did) ;
297
305
let candidates: Vec < _ > = impls
298
306
. flat_map ( |impl_outer| {
@@ -316,7 +324,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
316
324
)
317
325
} )
318
326
// TODO: this collect seems a shame
319
- . collect ( )
327
+ . collect :: < Vec < _ > > ( )
320
328
} else {
321
329
// These are provided methods or default types:
322
330
// ```
@@ -326,17 +334,14 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
326
334
// }
327
335
// ```
328
336
// 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 )
334
338
}
335
339
}
336
340
_ => panic ! ( "get_impls returned something that wasn't an impl" ) ,
337
341
}
338
342
} )
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_)))
340
345
. collect ( ) ;
341
346
if candidates. len ( ) > 1 {
342
347
let candidates = candidates. into_iter ( )
0 commit comments