@@ -285,20 +285,33 @@ impl<'tcx> MarkSymbolVisitor<'tcx> {
285
285
let def = self . tcx . adt_def ( item. def_id ) ;
286
286
self . repr_has_repr_c = def. repr ( ) . c ( ) ;
287
287
288
- intravisit:: walk_item ( self , & item) ;
289
- }
290
- hir:: ItemKind :: Enum ( ..) => {
291
- intravisit:: walk_item ( self , & item) ;
288
+ intravisit:: walk_item ( self , & item)
292
289
}
293
290
hir:: ItemKind :: ForeignMod { .. } => { }
294
- _ => {
295
- intravisit:: walk_item ( self , & item) ;
296
- }
291
+ _ => intravisit:: walk_item ( self , & item) ,
297
292
} ,
298
293
Node :: TraitItem ( trait_item) => {
299
294
intravisit:: walk_trait_item ( self , trait_item) ;
300
295
}
301
296
Node :: ImplItem ( impl_item) => {
297
+ let item = self . tcx . local_parent ( impl_item. def_id ) ;
298
+ if self . tcx . impl_trait_ref ( item) . is_none ( ) {
299
+ //// If it's a type whose items are live, then it's live, too.
300
+ //// This is done to handle the case where, for example, the static
301
+ //// method of a private type is used, but the type itself is never
302
+ //// called directly.
303
+ let self_ty = self . tcx . type_of ( item) ;
304
+ match * self_ty. kind ( ) {
305
+ ty:: Adt ( def, _) => self . check_def_id ( def. did ( ) ) ,
306
+ ty:: Foreign ( did) => self . check_def_id ( did) ,
307
+ ty:: Dynamic ( data, ..) => {
308
+ if let Some ( def_id) = data. principal_def_id ( ) {
309
+ self . check_def_id ( def_id)
310
+ }
311
+ }
312
+ _ => { }
313
+ }
314
+ }
302
315
intravisit:: walk_impl_item ( self , impl_item) ;
303
316
}
304
317
Node :: ForeignItem ( foreign_item) => {
@@ -671,24 +684,7 @@ impl<'tcx> DeadVisitor<'tcx> {
671
684
672
685
// id := HIR id of an item's definition.
673
686
fn symbol_is_live ( & mut self , def_id : LocalDefId ) -> bool {
674
- if self . live_symbols . contains ( & def_id) {
675
- return true ;
676
- }
677
- // If it's a type whose items are live, then it's live, too.
678
- // This is done to handle the case where, for example, the static
679
- // method of a private type is used, but the type itself is never
680
- // called directly.
681
- let inherent_impls = self . tcx . inherent_impls ( def_id) ;
682
- for & impl_did in inherent_impls. iter ( ) {
683
- for item_did in self . tcx . associated_item_def_ids ( impl_did) {
684
- if let Some ( def_id) = item_did. as_local ( )
685
- && self . live_symbols . contains ( & def_id)
686
- {
687
- return true ;
688
- }
689
- }
690
- }
691
- false
687
+ self . live_symbols . contains ( & def_id)
692
688
}
693
689
694
690
fn warn_multiple_dead_codes (
0 commit comments