Skip to content

Commit db78ab7

Browse files
committed
Auto merge of #98961 - zeevm:issue-98958-fix, r=oli-obk
Only enable ConstProp on opt level >= 1 r? `@JakobDegen`
2 parents 47575bb + 728fb05 commit db78ab7

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

Diff for: compiler/rustc_mir_transform/src/const_prop.rs

+2-11
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,8 @@ macro_rules! throw_machine_stop_str {
5959
pub struct ConstProp;
6060

6161
impl<'tcx> MirPass<'tcx> for ConstProp {
62-
fn is_enabled(&self, _sess: &rustc_session::Session) -> bool {
63-
// FIXME(#70073): Unlike the other passes in "optimizations", this one emits errors, so it
64-
// runs even when MIR optimizations are disabled. We should separate the lint out from the
65-
// transform and move the lint as early in the pipeline as possible.
66-
true
62+
fn is_enabled(&self, sess: &rustc_session::Session) -> bool {
63+
sess.mir_opt_level() >= 1
6764
}
6865

6966
#[instrument(skip(self, tcx), level = "debug")]
@@ -794,12 +791,6 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
794791

795792
/// Returns `true` if and only if this `op` should be const-propagated into.
796793
fn should_const_prop(&mut self, op: &OpTy<'tcx>) -> bool {
797-
let mir_opt_level = self.tcx.sess.mir_opt_level();
798-
799-
if mir_opt_level == 0 {
800-
return false;
801-
}
802-
803794
if !self.tcx.consider_optimizing(|| format!("ConstantPropagation - OpTy: {:?}", op)) {
804795
return false;
805796
}

0 commit comments

Comments
 (0)