Skip to content

Commit 099cb5a

Browse files
author
Ze'ev Maor
committed
only enable ConstProp on opt level 2
1 parent 41ad4d9 commit 099cb5a

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
@@ -60,11 +60,8 @@ macro_rules! throw_machine_stop_str {
6060
pub struct ConstProp;
6161

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

7067
#[instrument(skip(self, tcx), level = "debug")]
@@ -786,12 +783,6 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
786783

787784
/// Returns `true` if and only if this `op` should be const-propagated into.
788785
fn should_const_prop(&mut self, op: &OpTy<'tcx>) -> bool {
789-
let mir_opt_level = self.tcx.sess.mir_opt_level();
790-
791-
if mir_opt_level == 0 {
792-
return false;
793-
}
794-
795786
if !self.tcx.consider_optimizing(|| format!("ConstantPropagation - OpTy: {:?}", op)) {
796787
return false;
797788
}

0 commit comments

Comments
 (0)