2023-07-22 10:34:54 -05:00
|
|
|
//@ unit-test: UnreachablePropagation
|
2023-06-08 02:18:34 -05:00
|
|
|
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
|
2023-07-22 10:34:54 -05:00
|
|
|
|
2020-01-10 13:15:16 -06:00
|
|
|
pub enum Empty {}
|
|
|
|
|
|
|
|
fn empty() -> Option<Empty> {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
|
|
|
|
fn loop_forever() {
|
|
|
|
loop {}
|
|
|
|
}
|
|
|
|
|
2020-07-27 14:22:43 -05:00
|
|
|
// EMIT_MIR unreachable_diverging.main.UnreachablePropagation.diff
|
2020-01-10 13:15:16 -06:00
|
|
|
fn main() {
|
2023-07-22 10:34:54 -05:00
|
|
|
// CHECK-LABEL: fn main(
|
|
|
|
// CHECK: bb0: {
|
|
|
|
// CHECK: {{_.*}} = empty()
|
|
|
|
// CHECK: bb1: {
|
|
|
|
// CHECK: switchInt({{.*}}) -> [1: bb2, otherwise: bb6];
|
|
|
|
// CHECK: bb2: {
|
2023-07-22 10:34:42 -05:00
|
|
|
// CHECK: [[ne:_.*]] = Ne({{.*}}, const false);
|
|
|
|
// CHECK: assume(move [[ne]]);
|
|
|
|
// CHECK: goto -> bb3;
|
2023-07-22 10:34:54 -05:00
|
|
|
// CHECK: bb3: {
|
|
|
|
// CHECK: {{_.*}} = loop_forever()
|
|
|
|
// CHECK: bb4: {
|
|
|
|
// CHECK: unreachable;
|
|
|
|
// CHECK: bb5: {
|
|
|
|
// CHECK: unreachable;
|
|
|
|
// CHECK: bb6: {
|
|
|
|
// CHECK: return;
|
2020-01-10 13:15:16 -06:00
|
|
|
let x = true;
|
|
|
|
if let Some(bomb) = empty() {
|
|
|
|
if x {
|
|
|
|
loop_forever()
|
|
|
|
}
|
|
|
|
match bomb {}
|
|
|
|
}
|
|
|
|
}
|