]> git.lizzy.rs Git - rust.git/blobdiff - src/test/mir-opt/remove_fake_borrows.rs
Auto merge of #57609 - matthewjasper:more-restrictive-match, r=pnkfelix
[rust.git] / src / test / mir-opt / remove_fake_borrows.rs
index 8411fba02e97766244669818182bd50866855617..48d1c991b623ed981eda7306d6d21e87eae7e701 100644 (file)
 
 #![feature(nll)]
 
-fn match_guard(x: Option<&&i32>) -> i32 {
+fn match_guard(x: Option<&&i32>, c: bool) -> i32 {
     match x {
-        Some(0) if true => 0,
+        Some(0) if c => 0,
         _ => 1,
     }
 }
 
 fn main() {
-    match_guard(None);
+    match_guard(None, true);
 }
 
 // END RUST SOURCE
 
-// START rustc.match_guard.CleanFakeReadsAndBorrows.before.mir
+// START rustc.match_guard.CleanupNonCodegenStatements.before.mir
 // bb0: {
 //     FakeRead(ForMatchedPlace, _1);
-//     _2 = discriminant(_1);
-//     _3 = &shallow _1;
-//     _4 = &shallow ((_1 as Some).0: &'<empty> &'<empty> i32);
-//     _5 = &shallow (*((_1 as Some).0: &'<empty> &'<empty> i32));
-//     _6 = &shallow (*(*((_1 as Some).0: &'<empty> &'<empty> i32)));
-//     switchInt(move _2) -> [1isize: bb6, otherwise: bb4];
+//     _3 = discriminant(_1);
+//     switchInt(move _3) -> [1isize: bb5, otherwise: bb2];
 // }
 // bb1: {
-//     _0 = const 0i32;
-//     goto -> bb9;
+//     goto -> bb7;
 // }
 // bb2: {
-//     _0 = const 1i32;
-//     goto -> bb9;
+//     goto -> bb8;
 // }
 // bb3: {
-//     FakeRead(ForMatchGuard, _3);
-//     FakeRead(ForMatchGuard, _4);
-//     FakeRead(ForMatchGuard, _5);
-//     FakeRead(ForMatchGuard, _6);
-//     goto -> bb7;
+//     unreachable;
 // }
 // bb4: {
-//     FakeRead(ForMatchGuard, _3);
-//     FakeRead(ForMatchGuard, _4);
-//     FakeRead(ForMatchGuard, _5);
-//     FakeRead(ForMatchGuard, _6);
 //     goto -> bb2;
 // }
 // bb5: {
-//     unreachable;
+//     switchInt((*(*((_1 as Some).0: &'<empty> &'<empty> i32)))) -> [0i32: bb1, otherwise: bb2];
 // }
 // bb6: {
-//     switchInt((*(*((_1 as Some).0: &'<empty> &'<empty> i32)))) -> [0i32: bb3, otherwise: bb4];
+//     _0 = const 0i32;
+//     goto -> bb9;
 // }
 // bb7: {
-//     goto -> bb1;
+//     _4 = &shallow _1;
+//     _5 = &shallow ((_1 as Some).0: &'<empty> &'<empty> i32);
+//     _6 = &shallow (*((_1 as Some).0: &'<empty> &'<empty> i32));
+//     _7 = &shallow (*(*((_1 as Some).0: &'<empty> &'<empty> i32)));
+//     StorageLive(_8);
+//     _8 = _2;
+//     FakeRead(ForMatchGuard, _4);
+//     FakeRead(ForMatchGuard, _5);
+//     FakeRead(ForMatchGuard, _6);
+//     FakeRead(ForMatchGuard, _7);
+//     switchInt(move _8) -> [false: bb4, otherwise: bb6];
 // }
 // bb8: {
-//     goto -> bb4;
+//     _0 = const 1i32;
+//     goto -> bb9;
 // }
 // bb9: {
+//     StorageDead(_8);
 //     return;
 // }
 // bb10: {
 //     resume;
 // }
-// END rustc.match_guard.CleanFakeReadsAndBorrows.before.mir
+// END rustc.match_guard.CleanupNonCodegenStatements.before.mir
 
-// START rustc.match_guard.CleanFakeReadsAndBorrows.after.mir
+// START rustc.match_guard.CleanupNonCodegenStatements.after.mir
 // bb0: {
 //     nop;
-//     _2 = discriminant(_1);
-//     nop;
-//     nop;
-//     nop;
-//     nop;
-//     switchInt(move _2) -> [1isize: bb6, otherwise: bb4];
+//     _3 = discriminant(_1);
+//     switchInt(move _3) -> [1isize: bb5, otherwise: bb2];
 // }
 // bb1: {
-//     _0 = const 0i32;
-//     goto -> bb9;
+//     goto -> bb7;
 // }
 // bb2: {
-//     _0 = const 1i32;
-//     goto -> bb9;
+//     goto -> bb8;
 // }
 // bb3: {
-//     nop;
-//     nop;
-//     nop;
-//     nop;
-//     goto -> bb7;
+//     unreachable;
 // }
 // bb4: {
-//     nop;
-//     nop;
-//     nop;
-//     nop;
 //     goto -> bb2;
 // }
 // bb5: {
-//     unreachable;
+//     switchInt((*(*((_1 as Some).0: &'<empty> &'<empty> i32)))) -> [0i32: bb1, otherwise: bb2];
 // }
 // bb6: {
-//     switchInt((*(*((_1 as Some).0: &'<empty> &'<empty> i32)))) -> [0i32: bb3, otherwise: bb4];
+//     _0 = const 0i32;
+//     goto -> bb9;
 // }
 // bb7: {
-//     goto -> bb1;
+//     nop;
+//     nop;
+//     nop;
+//     nop;
+//     StorageLive(_8);
+//     _8 = _2;
+//     nop;
+//     nop;
+//     nop;
+//     nop;
+//     switchInt(move _8) -> [false: bb4, otherwise: bb6];
 // }
 // bb8: {
-//     goto -> bb4;
+//     _0 = const 1i32;
+//     goto -> bb9;
 // }
 // bb9: {
+//     StorageDead(_8);
 //     return;
 // }
 // bb10: {
 //     resume;
 // }
-// END rustc.match_guard.CleanFakeReadsAndBorrows.after.mir
+// END rustc.match_guard.CleanupNonCodegenStatements.after.mir