rust/tests/mir-opt/unreachable.rs
Nicholas Nethercote c9c80d2c5f rustfmt tests/mir-opt.
The only non-obvious changes:
- `building/storage_live_dead_in_statics.rs` has a `#[rustfmt::skip]`
  attribute to avoid reformating a table of data.
- Two `.mir` files have slight changes involving line numbers.
- In `unusual_item_types.rs` an `EMIT_MIR` annotation is moved to
  outside a function, which is the usual spot, because `tidy` complains
  if such a comment is indented.

The commit also tweaks the comments in `rustfmt.toml`.
2024-06-03 14:17:16 +10:00

67 lines
1.4 KiB
Rust

//@ test-mir-pass: UnreachablePropagation
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
enum Empty {}
fn empty() -> Option<Empty> {
None
}
// EMIT_MIR unreachable.if_let.UnreachablePropagation.diff
fn if_let() {
// CHECK-LABEL: fn if_let(
// CHECK: bb0: {
// CHECK: {{_.*}} = empty()
// CHECK: bb1: {
// CHECK: [[ne:_.*]] = Ne({{.*}}, const 1_isize);
// CHECK-NEXT: assume(move [[ne]]);
// CHECK-NEXT: goto -> bb6;
// CHECK: bb2: {
// CHECK-NEXT: unreachable;
// CHECK: bb3: {
// CHECK-NEXT: unreachable;
// CHECK: bb4: {
// CHECK-NEXT: unreachable;
// CHECK: bb5: {
// CHECK-NEXT: unreachable;
// CHECK: bb6: {
// CHECK: return;
if let Some(_x) = empty() {
let mut _y;
if true {
_y = 21;
} else {
_y = 42;
}
match _x {}
}
}
// EMIT_MIR unreachable.as_match.UnreachablePropagation.diff
fn as_match() {
// CHECK-LABEL: fn as_match(
// CHECK: bb0: {
// CHECK: {{_.*}} = empty()
// CHECK: bb1: {
// CHECK: [[eq:_.*]] = Eq({{.*}}, const 0_isize);
// CHECK-NEXT: assume(move [[eq]]);
// CHECK-NEXT: goto -> bb4;
// CHECK: bb2: {
// CHECK-NEXT: unreachable;
// CHECK: bb3: {
// CHECK-NEXT: unreachable;
// CHECK: bb4: {
// CHECK: return;
match empty() {
None => {}
Some(_x) => match _x {},
}
}
fn main() {
if_let();
as_match();
}