diff options
| -rw-r--r-- | tests/mir-opt/matches_reduce_branches.my_is_some.MatchBranchSimplification.diff | 32 | ||||
| -rw-r--r-- | tests/mir-opt/matches_reduce_branches.rs | 14 |
2 files changed, 46 insertions, 0 deletions
diff --git a/tests/mir-opt/matches_reduce_branches.my_is_some.MatchBranchSimplification.diff b/tests/mir-opt/matches_reduce_branches.my_is_some.MatchBranchSimplification.diff new file mode 100644 index 00000000000..d55e764e1c2 --- /dev/null +++ b/tests/mir-opt/matches_reduce_branches.my_is_some.MatchBranchSimplification.diff @@ -0,0 +1,32 @@ +- // MIR for `my_is_some` before MatchBranchSimplification ++ // MIR for `my_is_some` after MatchBranchSimplification + + fn my_is_some(_1: Option<()>) -> bool { + debug bar => _1; + let mut _0: bool; + let mut _2: isize; + + bb0: { + _2 = discriminant(_1); + switchInt(move _2) -> [0: bb2, 1: bb3, otherwise: bb1]; + } + + bb1: { + unreachable; + } + + bb2: { + _0 = const false; + goto -> bb4; + } + + bb3: { + _0 = const true; + goto -> bb4; + } + + bb4: { + return; + } + } + diff --git a/tests/mir-opt/matches_reduce_branches.rs b/tests/mir-opt/matches_reduce_branches.rs index 6787e5816a3..e2bd7b3459c 100644 --- a/tests/mir-opt/matches_reduce_branches.rs +++ b/tests/mir-opt/matches_reduce_branches.rs @@ -19,6 +19,18 @@ fn foo(bar: Option<()>) { } } +// EMIT_MIR matches_reduce_branches.my_is_some.MatchBranchSimplification.diff +// Test for #131219. +fn my_is_some(bar: Option<()>) -> bool { + // CHECK-LABEL: fn my_is_some( + // CHECK: switchInt + // CHECK: return + match bar { + Some(_) => true, + None => false, + } +} + // EMIT_MIR matches_reduce_branches.bar.MatchBranchSimplification.diff fn bar(i: i32) -> (bool, bool, bool, bool) { // CHECK-LABEL: fn bar( @@ -651,4 +663,6 @@ fn main() { let _: u8 = match_trunc_u16_u8_failed(EnumAu16::u0_0x0000); let _ = match_i128_u128(EnumAi128::A); + + let _ = my_is_some(None); } |
