@@ -330,11 +330,12 @@ fn has_allow_dead_code_or_lang_attr(attrs: &[ast::Attribute]) -> bool {
330330// or
331331// 2) We are not sure to be live or not
332332// * Implementation of a trait method
333- struct LifeSeeder {
334- worklist : Vec < ast:: NodeId >
333+ struct LifeSeeder < ' k > {
334+ worklist : Vec < ast:: NodeId > ,
335+ krate : & ' k hir:: Crate ,
335336}
336337
337- impl < ' v > ItemLikeVisitor < ' v > for LifeSeeder {
338+ impl < ' v , ' k > ItemLikeVisitor < ' v > for LifeSeeder < ' k > {
338339 fn visit_item ( & mut self , item : & hir:: Item ) {
339340 let allow_dead_code = has_allow_dead_code_or_lang_attr ( & item. attrs ) ;
340341 if allow_dead_code {
@@ -358,17 +359,22 @@ impl<'v> ItemLikeVisitor<'v> for LifeSeeder {
358359 }
359360 }
360361 }
361- hir:: ItemImpl ( .., ref opt_trait, _, ref impl_items) => {
362- for impl_item in impl_items {
362+ hir:: ItemImpl ( .., ref opt_trait, _, ref impl_item_ids) => {
363+ for & impl_item_id in impl_item_ids {
364+ let impl_item = self . krate . impl_item ( impl_item_id) ;
363365 if opt_trait. is_some ( ) ||
364366 has_allow_dead_code_or_lang_attr ( & impl_item. attrs ) {
365- self . worklist . push ( impl_item . id ) ;
367+ self . worklist . push ( impl_item_id . id ) ;
366368 }
367369 }
368370 }
369371 _ => ( )
370372 }
371373 }
374+
375+ fn visit_impl_item ( & mut self , _item : & hir:: ImplItem ) {
376+ // ignore: we are handling this in `visit_item` above
377+ }
372378}
373379
374380fn create_and_seed_worklist < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
@@ -387,7 +393,8 @@ fn create_and_seed_worklist<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
387393
388394 // Seed implemented trait items
389395 let mut life_seeder = LifeSeeder {
390- worklist : worklist
396+ worklist : worklist,
397+ krate : krate,
391398 } ;
392399 krate. visit_all_item_likes ( & mut life_seeder) ;
393400
@@ -510,8 +517,13 @@ impl<'a, 'tcx, 'v> Visitor<'v> for DeadVisitor<'a, 'tcx> {
510517 /// an error. We could do this also by checking the parents, but
511518 /// this is how the code is setup and it seems harmless enough.
512519 fn visit_nested_item ( & mut self , item : hir:: ItemId ) {
513- let tcx = self . tcx ;
514- self . visit_item ( tcx. map . expect_item ( item. id ) )
520+ let item = self . tcx . map . expect_item ( item. id ) ;
521+ self . visit_item ( item)
522+ }
523+
524+ fn visit_nested_impl_item ( & mut self , item_id : hir:: ImplItemId ) {
525+ let impl_item = self . tcx . map . impl_item ( item_id) ;
526+ self . visit_impl_item ( impl_item)
515527 }
516528
517529 fn visit_item ( & mut self , item : & hir:: Item ) {
0 commit comments