File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -1186,6 +1186,13 @@ struct RootCollector<'a, 'tcx> {
11861186
11871187impl < ' v > RootCollector < ' _ , ' v > {
11881188 fn process_item ( & mut self , id : hir:: ItemId ) {
1189+ let def_id = id. owner_id . def_id ;
1190+ let ( live_symbols, _) = self . tcx . live_symbols_and_ignored_derived_traits ( ( ) ) ;
1191+ if !live_symbols. contains ( & def_id) && !self . tcx . sess . link_dead_code ( ) {
1192+ // This is dead code; ignore it.
1193+ return ;
1194+ }
1195+
11891196 match self . tcx . def_kind ( id. owner_id ) {
11901197 DefKind :: Enum | DefKind :: Struct | DefKind :: Union => {
11911198 let item = self . tcx . hir ( ) . item ( id) ;
Original file line number Diff line number Diff line change @@ -623,6 +623,11 @@ fn create_and_seed_worklist<'tcx>(
623623 check_foreign_item ( tcx, & mut worklist, id) ;
624624 }
625625
626+ if let Some ( static_) = tcx. proc_macro_decls_static ( ( ) ) {
627+ // We assume this is always used if present.
628+ worklist. push ( static_) ;
629+ }
630+
626631 ( worklist, struct_constructors)
627632}
628633
You can’t perform that action at this time.
0 commit comments