about summary refs log tree commit diff
path: root/tests/mir-opt/read_from_trivial_switch.rs
blob: 1c64c1d45e831e344a15898f94c5927bdeef17f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// Ensure that we don't optimize out `SwitchInt` reads even if that terminator
// branches to the same basic block on every target, since the operand may have
// side-effects that affect analysis of the MIR.
//
// See <https://github.com/rust-lang/miri/issues/4237>.

//@ test-mir-pass: SimplifyCfg-initial
//@ compile-flags: -Zmir-preserve-ub

// EMIT_MIR read_from_trivial_switch.main.SimplifyCfg-initial.diff
fn main() {
    let ref_ = &1i32;
    // CHECK: switchInt
    let &(0 | _) = ref_;
}