Skip to content

Commit b4e3de0

Browse files
committed
Run MatchBranchSimplification with opt-level 2
1 parent 05f417c commit b4e3de0

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

compiler/rustc_mir_transform/src/match_branches.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ pub(super) struct MatchBranchSimplification;
1414

1515
impl<'tcx> crate::MirPass<'tcx> for MatchBranchSimplification {
1616
fn is_enabled(&self, sess: &rustc_session::Session) -> bool {
17-
sess.mir_opt_level() >= 1
17+
// Enable only under -Zmir-opt-level=2 as this can make programs less debuggable.
18+
sess.mir_opt_level() >= 2
1819
}
1920

2021
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {

tests/mir-opt/simplify_locals_fixedpoint.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
// skip-filecheck
21
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
3-
//@ compile-flags: -Zmir-opt-level=1
2+
//@ compile-flags: -Zmir-opt-level=1 -Zmir-enable-passes=+MatchBranchSimplification
43

4+
// EMIT_MIR simplify_locals_fixedpoint.foo.SimplifyLocals-final.diff
55
fn foo<T>() {
6+
// CHECK-LABEL: fn foo(
7+
// CHECK-NOT: let mut {{.*}}: bool;
8+
// CHECK-NOT: let mut {{.*}}: u8;
9+
// CHECK-NOT: let mut {{.*}}: bool;
610
if let (Some(a), None) = (Option::<u8>::None, Option::<T>::None) {
711
if a > 42u8 {}
812
}
@@ -11,5 +15,3 @@ fn foo<T>() {
1115
fn main() {
1216
foo::<()>();
1317
}
14-
15-
// EMIT_MIR simplify_locals_fixedpoint.foo.SimplifyLocals-final.diff

0 commit comments

Comments
 (0)