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