From 98255cc2424b8ad3de462dc4241e14e23b1aa5c5 Mon Sep 17 00:00:00 2001 From: Camille GILLOT <gillot.camille@gmail.com> Date: Tue, 4 Apr 2023 17:14:53 +0000 Subject: [PATCH] Comment logic around worklist. --- compiler/rustc_mir_transform/src/const_prop_lint.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/compiler/rustc_mir_transform/src/const_prop_lint.rs b/compiler/rustc_mir_transform/src/const_prop_lint.rs index 99bdb831c75..942ccd5a9d1 100644 --- a/compiler/rustc_mir_transform/src/const_prop_lint.rs +++ b/compiler/rustc_mir_transform/src/const_prop_lint.rs @@ -675,10 +675,13 @@ impl<'tcx> Visitor<'tcx> for ConstPropagator<'_, 'tcx> { && let Ok(constant) = value_const.try_to_int() && let Ok(constant) = constant.to_bits(constant.size()) { + // We managed to evaluate the discriminant, so we know we only need to visit + // one target. let target = targets.target_for_value(constant); self.worklist.push(target); return; } + // We failed to evaluate the discriminant, fallback to visiting all successors. } // None of these have Operands to const-propagate. TerminatorKind::Goto { .. }