diff --git a/compiler/rustc_mir/src/transform/early_otherwise_branch.rs b/compiler/rustc_mir/src/transform/early_otherwise_branch.rs index e64a539c7f8e4..f7ea9faec4728 100644 --- a/compiler/rustc_mir/src/transform/early_otherwise_branch.rs +++ b/compiler/rustc_mir/src/transform/early_otherwise_branch.rs @@ -26,6 +26,11 @@ pub struct EarlyOtherwiseBranch; impl<'tcx> MirPass<'tcx> for EarlyOtherwiseBranch { fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { + // FIXME(#78496) + if !tcx.sess.opts.debugging_opts.unsound_mir_opts { + return; + } + if tcx.sess.mir_opt_level() < 3 { return; } diff --git a/src/test/mir-opt/early_otherwise_branch.rs b/src/test/mir-opt/early_otherwise_branch.rs index 548213ab83caf..b2caf7d7b8fde 100644 --- a/src/test/mir-opt/early_otherwise_branch.rs +++ b/src/test/mir-opt/early_otherwise_branch.rs @@ -1,4 +1,4 @@ -// compile-flags: -Z mir-opt-level=4 +// compile-flags: -Z mir-opt-level=4 -Z unsound-mir-opts // EMIT_MIR early_otherwise_branch.opt1.EarlyOtherwiseBranch.diff fn opt1(x: Option, y: Option) -> u32 { match (x, y) { diff --git a/src/test/mir-opt/early_otherwise_branch_3_element_tuple.rs b/src/test/mir-opt/early_otherwise_branch_3_element_tuple.rs index aa304f747f748..8527c01d75658 100644 --- a/src/test/mir-opt/early_otherwise_branch_3_element_tuple.rs +++ b/src/test/mir-opt/early_otherwise_branch_3_element_tuple.rs @@ -1,4 +1,4 @@ -// compile-flags: -Z mir-opt-level=4 +// compile-flags: -Z mir-opt-level=4 -Z unsound-mir-opts // EMIT_MIR early_otherwise_branch_3_element_tuple.opt1.EarlyOtherwiseBranch.diff fn opt1(x: Option, y: Option, z: Option) -> u32 {