diff options
| author | bors <bors@rust-lang.org> | 2022-07-09 02:04:17 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-07-09 02:04:17 +0000 |
| commit | db78ab70a88a0a5e89031d7ee4eccec835dcdbde (patch) | |
| tree | 3af4a1031ae19af04e6f21417c19f2b1e0e498d7 /compiler/rustc_mir_transform/src | |
| parent | 47575bb066f2723f8386a08b4ced872f94c7e249 (diff) | |
| parent | 728fb05f1fc3d4ab4db5764395fc9ac34efc45f0 (diff) | |
| download | rust-db78ab70a88a0a5e89031d7ee4eccec835dcdbde.tar.gz rust-db78ab70a88a0a5e89031d7ee4eccec835dcdbde.zip | |
Auto merge of #98961 - zeevm:issue-98958-fix, r=oli-obk
Only enable ConstProp on opt level >= 1 r? `@JakobDegen`
Diffstat (limited to 'compiler/rustc_mir_transform/src')
| -rw-r--r-- | compiler/rustc_mir_transform/src/const_prop.rs | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/compiler/rustc_mir_transform/src/const_prop.rs b/compiler/rustc_mir_transform/src/const_prop.rs index 01eda979f9e..185f6c523d3 100644 --- a/compiler/rustc_mir_transform/src/const_prop.rs +++ b/compiler/rustc_mir_transform/src/const_prop.rs @@ -59,11 +59,8 @@ macro_rules! throw_machine_stop_str { pub struct ConstProp; impl<'tcx> MirPass<'tcx> for ConstProp { - fn is_enabled(&self, _sess: &rustc_session::Session) -> bool { - // FIXME(#70073): Unlike the other passes in "optimizations", this one emits errors, so it - // runs even when MIR optimizations are disabled. We should separate the lint out from the - // transform and move the lint as early in the pipeline as possible. - true + fn is_enabled(&self, sess: &rustc_session::Session) -> bool { + sess.mir_opt_level() >= 1 } #[instrument(skip(self, tcx), level = "debug")] @@ -794,12 +791,6 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { /// Returns `true` if and only if this `op` should be const-propagated into. fn should_const_prop(&mut self, op: &OpTy<'tcx>) -> bool { - let mir_opt_level = self.tcx.sess.mir_opt_level(); - - if mir_opt_level == 0 { - return false; - } - if !self.tcx.consider_optimizing(|| format!("ConstantPropagation - OpTy: {:?}", op)) { return false; } |
