#![feature(custom_mir, core_intrinsics)]
use std::intrinsics::mir::*;
#[custom_mir(dialect = "runtime")]
fn main() {
mir! {
let a: u64;
let b: u64;
{ a = 1; StorageDead(b); match a { 0 => bb1, _ => bb3 }}
bb1 = { match b { 0 => bb1, _ => bb3 } }
bb2 = { Goto(bb4) }
bb3 = { Goto(bb4) }
bb4 = { Return() }
}
}
rustc -Zmir-opt-level=0 -Zmir-enable-passes=+EarlyOtherwiseBranch a.rs -Zunpretty=mir
fn main() -> () {
let mut _0: ();
let mut _1: u64;
let mut _2: u64;
let mut _3: bool;
let mut _4: bool;
bb0: {
_1 = const 1_u64;
StorageDead(_2);
_3 = Ne(copy _1, copy _2); // undefined behavior: _2 is dead
switchInt(move _3) -> [0: bb3, otherwise: bb2];
}
bb1: {
_4 = Ne(copy _2, copy _2);
switchInt(move _4) -> [0: bb4, otherwise: bb2];
}
bb2: {
return;
}
bb3: {
switchInt(copy _1) -> [0: bb1, otherwise: bb2];
}
bb4: {
switchInt(copy _2) -> [0: bb1, otherwise: bb2];
}
}
Related to #159591. Pending fix appears to be quite specific to that issue, and doesn't resolve the one here.
Meta
rustc --version --verbose:
rustc 1.99.0-nightly (9f36de775 2026-07-19)
binary: rustc
commit-hash: 9f36de775bc636c8e88c31a173c2bcb6995956a0
commit-date: 2026-07-19
host: x86_64-unknown-linux-gnu
release: 1.99.0-nightly
LLVM version: 22.1.8
rustc -Zmir-opt-level=0 -Zmir-enable-passes=+EarlyOtherwiseBranch a.rs -Zunpretty=mirRelated to #159591. Pending fix appears to be quite specific to that issue, and doesn't resolve the one here.
Meta
rustc --version --verbose: