2024-04-20 06:19:34 -05:00
|
|
|
//@ test-mir-pass: 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
|
|
|
enum Empty {}
|
|
|
|
|
|
|
|
fn empty() -> Option<Empty> {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
|
2023-09-24 03:27:42 -05:00
|
|
|
// EMIT_MIR unreachable.if_let.UnreachablePropagation.diff
|
|
|
|
fn if_let() {
|
|
|
|
// CHECK-LABEL: fn if_let(
|
2023-07-22 10:34:54 -05:00
|
|
|
// CHECK: bb0: {
|
|
|
|
// CHECK: {{_.*}} = empty()
|
|
|
|
// CHECK: bb1: {
|
2023-07-22 10:34:42 -05:00
|
|
|
// CHECK: [[ne:_.*]] = Ne({{.*}}, const 1_isize);
|
|
|
|
// CHECK-NEXT: assume(move [[ne]]);
|
|
|
|
// CHECK-NEXT: goto -> bb6;
|
2023-07-22 10:34:54 -05:00
|
|
|
// CHECK: bb2: {
|
2023-07-22 10:34:42 -05:00
|
|
|
// CHECK-NEXT: unreachable;
|
2023-07-22 10:34:54 -05:00
|
|
|
// CHECK: bb3: {
|
2023-07-22 10:34:42 -05:00
|
|
|
// CHECK-NEXT: unreachable;
|
2023-07-22 10:34:54 -05:00
|
|
|
// CHECK: bb4: {
|
2023-07-22 10:34:42 -05:00
|
|
|
// CHECK-NEXT: unreachable;
|
2023-07-22 10:34:54 -05:00
|
|
|
// CHECK: bb5: {
|
2023-07-22 10:34:42 -05:00
|
|
|
// CHECK-NEXT: unreachable;
|
2023-07-22 10:34:54 -05:00
|
|
|
// CHECK: bb6: {
|
|
|
|
// CHECK: return;
|
2020-01-10 13:15:16 -06:00
|
|
|
if let Some(_x) = empty() {
|
|
|
|
let mut _y;
|
|
|
|
|
|
|
|
if true {
|
|
|
|
_y = 21;
|
|
|
|
} else {
|
|
|
|
_y = 42;
|
|
|
|
}
|
|
|
|
|
2024-06-02 19:18:33 -05:00
|
|
|
match _x {}
|
2020-01-10 13:15:16 -06:00
|
|
|
}
|
|
|
|
}
|
2023-09-24 03:27:42 -05:00
|
|
|
|
|
|
|
// EMIT_MIR unreachable.as_match.UnreachablePropagation.diff
|
|
|
|
fn as_match() {
|
|
|
|
// CHECK-LABEL: fn as_match(
|
|
|
|
// CHECK: bb0: {
|
|
|
|
// CHECK: {{_.*}} = empty()
|
|
|
|
// CHECK: bb1: {
|
2024-07-27 04:08:16 -05:00
|
|
|
// CHECK: [[eq:_.*]] = Ne({{.*}}, const 1_isize);
|
2023-09-24 03:27:42 -05:00
|
|
|
// CHECK-NEXT: assume(move [[eq]]);
|
2024-07-27 04:08:16 -05:00
|
|
|
// CHECK-NEXT: goto -> bb2;
|
2023-09-24 03:27:42 -05:00
|
|
|
// CHECK: bb2: {
|
2024-07-27 04:08:16 -05:00
|
|
|
// CHECK: return;
|
2023-09-24 03:27:42 -05:00
|
|
|
// CHECK: bb3: {
|
|
|
|
// CHECK-NEXT: unreachable;
|
|
|
|
match empty() {
|
2024-06-02 19:18:33 -05:00
|
|
|
Some(_x) => match _x {},
|
2024-07-27 04:08:16 -05:00
|
|
|
None => {}
|
2023-09-24 03:27:42 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
if_let();
|
|
|
|
as_match();
|
|
|
|
}
|