]> git.lizzy.rs Git - rust.git/blob - src/test/mir-opt/remove_fake_borrows.rs
Clean up MIR match lowering
[rust.git] / src / test / mir-opt / remove_fake_borrows.rs
1 // Test that the fake borrows for matches are removed after borrow checking.
2
3 // ignore-wasm32-bare
4
5 #![feature(nll)]
6
7 fn match_guard(x: Option<&&i32>, c: bool) -> i32 {
8     match x {
9         Some(0) if c => 0,
10         _ => 1,
11     }
12 }
13
14 fn main() {
15     match_guard(None, true);
16 }
17
18 // END RUST SOURCE
19
20 // START rustc.match_guard.CleanFakeReadsAndBorrows.before.mir
21 // bb0: {
22 //     FakeRead(ForMatchedPlace, _1);
23 //     _3 = discriminant(_1);
24 //     switchInt(move _3) -> [1isize: bb5, otherwise: bb2];
25 // }
26 // bb1: {
27 //     goto -> bb8;
28 // }
29 // bb2: {
30 //     goto -> bb9;
31 // }
32 // bb3: {
33 //     unreachable;
34 // }
35 // bb4: {
36 //     goto -> bb2;
37 // }
38 // bb5: {
39 //     switchInt((*(*((_1 as Some).0: &'<empty> &'<empty> i32)))) -> [0i32: bb1, otherwise: bb2];
40 // }
41 // bb6: {
42 //     StorageDead(_8);
43 //     return;
44 // }
45 // bb7: {
46 //     _0 = const 0i32;
47 //     goto -> bb6;
48 // }
49 // bb8: {
50 //     _4 = &shallow _1;
51 //     _5 = &shallow ((_1 as Some).0: &'<empty> &'<empty> i32);
52 //     _6 = &shallow (*((_1 as Some).0: &'<empty> &'<empty> i32));
53 //     _7 = &shallow (*(*((_1 as Some).0: &'<empty> &'<empty> i32)));
54 //     StorageLive(_8);
55 //     _8 = _2;
56 //     FakeRead(ForMatchGuard, _4);
57 //     FakeRead(ForMatchGuard, _5);
58 //     FakeRead(ForMatchGuard, _6);
59 //     FakeRead(ForMatchGuard, _7);
60 //     switchInt(move _8) -> [false: bb4, otherwise: bb7];
61 // }
62 // bb9: {
63 //     _0 = const 1i32;
64 //     goto -> bb6;
65 // }
66 // bb10: {
67 //     resume;
68 // }
69 // END rustc.match_guard.CleanFakeReadsAndBorrows.before.mir
70
71 // START rustc.match_guard.CleanFakeReadsAndBorrows.after.mir
72 // bb0: {
73 //     nop;
74 //     _3 = discriminant(_1);
75 //     switchInt(move _3) -> [1isize: bb5, otherwise: bb2];
76 // }
77 // bb1: {
78 //     goto -> bb8;
79 // }
80 // bb2: {
81 //     goto -> bb9;
82 // }
83 // bb3: {
84 //     unreachable;
85 // }
86 // bb4: {
87 //     goto -> bb2;
88 // }
89 // bb5: {
90 //     switchInt((*(*((_1 as Some).0: &'<empty> &'<empty> i32)))) -> [0i32: bb1, otherwise: bb2];
91 // }
92 // bb6: {
93 //     StorageDead(_8);
94 //     return;
95 // }
96 // bb7: {
97 //     _0 = const 0i32;
98 //     goto -> bb6;
99 // }
100 // bb8: {
101 //     nop;
102 //     nop;
103 //     nop;
104 //     nop;
105 //     StorageLive(_8);
106 //     _8 = _2;
107 //     nop;
108 //     nop;
109 //     nop;
110 //     nop;
111 //     switchInt(move _8) -> [false: bb4, otherwise: bb7];
112 // }
113 // bb9: {
114 //     _0 = const 1i32;
115 //     goto -> bb6;
116 // }
117 // bb10: {
118 //     resume;
119 //    }
120 // END rustc.match_guard.CleanFakeReadsAndBorrows.after.mir