diff --git a/compiler/rustc_passes/src/dead.rs b/compiler/rustc_passes/src/dead.rs index baf312b968638..3f01bf1f6136b 100644 --- a/compiler/rustc_passes/src/dead.rs +++ b/compiler/rustc_passes/src/dead.rs @@ -265,7 +265,11 @@ impl<'tcx> MarkSymbolVisitor<'tcx> { } self.insert_def_id(variant.fields[FieldIdx::from_usize(idx)].did); } - self.insert_def_id(variant.def_id); + if let Some(def_id) = variant.def_id.as_local() { + if should_explore(self.tcx, def_id) { + self.insert_def_id(variant.def_id); + } + } } fn handle_offset_of(&mut self, expr: &'tcx hir::Expr<'tcx>) {