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