@@ -759,6 +759,15 @@ fn maybe_record_as_seed<'tcx>(
759759 match tcx. def_kind ( parent) {
760760 DefKind :: Impl { of_trait : false } | DefKind :: Trait => { }
761761 DefKind :: Impl { of_trait : true } => {
762+ if let Some ( trait_item_def_id) =
763+ tcx. associated_item ( owner_id. def_id ) . trait_item_def_id
764+ && let Some ( trait_item_local_def_id) = trait_item_def_id. as_local ( )
765+ && let Some ( comes_from_allow) =
766+ has_allow_dead_code_or_lang_attr ( tcx, trait_item_local_def_id)
767+ {
768+ worklist. push ( ( owner_id. def_id , comes_from_allow) ) ;
769+ }
770+
762771 // We only care about associated items of traits,
763772 // because they cannot be visited directly,
764773 // so we later mark them as live if their corresponding traits
@@ -772,6 +781,15 @@ fn maybe_record_as_seed<'tcx>(
772781 }
773782 DefKind :: Impl { of_trait : true } => {
774783 if allow_dead_code. is_none ( ) {
784+ if let Some ( trait_def_id) = tcx
785+ . impl_trait_ref ( owner_id. def_id )
786+ . and_then ( |trait_ref| trait_ref. skip_binder ( ) . def_id . as_local ( ) )
787+ && let Some ( comes_from_allow) =
788+ has_allow_dead_code_or_lang_attr ( tcx, trait_def_id)
789+ {
790+ worklist. push ( ( owner_id. def_id , comes_from_allow) ) ;
791+ }
792+
775793 unsolved_items. push ( owner_id. def_id ) ;
776794 }
777795 }
0 commit comments