diff --git a/compiler/rustc_passes/src/dead.rs b/compiler/rustc_passes/src/dead.rs index 558ee27e0abf..543be9a3f071 100644 --- a/compiler/rustc_passes/src/dead.rs +++ b/compiler/rustc_passes/src/dead.rs @@ -367,10 +367,7 @@ fn mark_live_symbols(&mut self) -> as Visitor<'tcx>>::R continue; } - let visit_result = self.visit_node(self.tcx.hir_node_by_def_id(id)); - if visit_result.is_break() { - return visit_result; - } + self.visit_node(self.tcx.hir_node_by_def_id(id))?; } ControlFlow::Continue(()) @@ -1167,11 +1164,12 @@ fn is_live_code(&self, def_id: LocalDefId) -> bool { } fn check_mod_deathness(tcx: TyCtxt<'_>, module: LocalModDefId) { - let live_symbols_result = tcx.live_symbols_and_ignored_derived_traits(()); - if live_symbols_result.is_err() { + let Ok((live_symbols, ignored_derived_traits)) = + tcx.live_symbols_and_ignored_derived_traits(()).as_ref() + else { return; - } - let (live_symbols, ignored_derived_traits) = live_symbols_result.as_ref().unwrap(); + }; + let mut visitor = DeadVisitor { tcx, live_symbols, ignored_derived_traits }; let module_items = tcx.hir_module_items(module); diff --git a/tests/ui/consts/do-not-ice-long-constant-evaluation-in-for-loop.rs b/tests/ui/consts/do-not-ice-long-constant-evaluation-in-for-loop.rs index 2e12ba48fd25..465b54e69d1b 100644 --- a/tests/ui/consts/do-not-ice-long-constant-evaluation-in-for-loop.rs +++ b/tests/ui/consts/do-not-ice-long-constant-evaluation-in-for-loop.rs @@ -1,6 +1,7 @@ // The test confirms ICE-125323 is fixed. // -// This warning makes sure the fix doesn't throw everything with errors to dead. +// This warning tests there is no warning about dead code +// when there is a constant evaluation error. #![warn(unused)] fn should_not_be_dead() {} diff --git a/tests/ui/consts/do-not-ice-long-constant-evaluation-in-for-loop.stderr b/tests/ui/consts/do-not-ice-long-constant-evaluation-in-for-loop.stderr index d422ef2ddc47..32a18469ab9e 100644 --- a/tests/ui/consts/do-not-ice-long-constant-evaluation-in-for-loop.stderr +++ b/tests/ui/consts/do-not-ice-long-constant-evaluation-in-for-loop.stderr @@ -1,5 +1,5 @@ error: constant evaluation is taking a long time - --> $DIR/do-not-ice-long-constant-evaluation-in-for-loop.rs:9:14 + --> $DIR/do-not-ice-long-constant-evaluation-in-for-loop.rs:10:14 | LL | [(); loop {}]; | ^^^^^^^ @@ -7,7 +7,7 @@ LL | [(); loop {}]; = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. If your compilation actually takes a long time, you can safely allow the lint. help: the constant being evaluated - --> $DIR/do-not-ice-long-constant-evaluation-in-for-loop.rs:9:14 + --> $DIR/do-not-ice-long-constant-evaluation-in-for-loop.rs:10:14 | LL | [(); loop {}]; | ^^^^^^^