]> git.lizzy.rs Git - rust.git/blob - src/test/mir-opt/remove_fake_borrows.rs
Create fewer basic blocks in match MIR 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 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: bb3, otherwise: bb2];
23 // }
24 // bb1: {
25 //     goto -> bb4;
26 // }
27 // bb2: {
28 //     _0 = const 1i32;
29 //     goto -> bb7;
30 // }
31 // bb3: {
32 //     switchInt((*(*((_1 as Some).0: &'<empty> &'<empty> i32)))) -> [0i32: bb1, otherwise: bb2];
33 // }
34 // bb4: {
35 //     _4 = &shallow _1;
36 //     _5 = &shallow ((_1 as Some).0: &'<empty> &'<empty> i32);
37 //     _6 = &shallow (*((_1 as Some).0: &'<empty> &'<empty> i32));
38 //     _7 = &shallow (*(*((_1 as Some).0: &'<empty> &'<empty> i32)));
39 //     StorageLive(_8);
40 //     _8 = _2;
41 //     FakeRead(ForMatchGuard, _4);
42 //     FakeRead(ForMatchGuard, _5);
43 //     FakeRead(ForMatchGuard, _6);
44 //     FakeRead(ForMatchGuard, _7);
45 //     switchInt(move _8) -> [false: bb6, otherwise: bb5];
46 // }
47 // bb5: {
48 //     StorageDead(_8);
49 //     _0 = const 0i32;
50 //     goto -> bb7;
51 // }
52 // bb6: {
53 //     StorageDead(_8);
54 //     goto -> bb2;
55 // }
56 // bb7: {
57 //     return;
58 // }
59 // bb8 (cleanup): {
60 //     resume;
61 // }
62 // END rustc.match_guard.CleanupNonCodegenStatements.before.mir
63
64 // START rustc.match_guard.CleanupNonCodegenStatements.after.mir
65 // bb0: {
66 //     nop;
67 //     _3 = discriminant(_1);
68 //     switchInt(move _3) -> [1isize: bb3, otherwise: bb2];
69 // }
70 // bb1: {
71 //     goto -> bb4;
72 // }
73 // bb2: {
74 //     _0 = const 1i32;
75 //     goto -> bb7;
76 // }
77 // bb3: {
78 //     switchInt((*(*((_1 as Some).0: &'<empty> &'<empty> i32)))) -> [0i32: bb1, otherwise: bb2];
79 // }
80 // bb4: {
81 //     nop;
82 //     nop;
83 //     nop;
84 //     nop;
85 //     StorageLive(_8);
86 //     _8 = _2;
87 //     nop;
88 //     nop;
89 //     nop;
90 //     nop;
91 //     switchInt(move _8) -> [false: bb6, otherwise: bb5];
92 // }
93 // bb5: {
94 //     StorageDead(_8);
95 //     _0 = const 0i32;
96 //     goto -> bb7;
97 // }
98 // bb6: {
99 //     StorageDead(_8);
100 //     goto -> bb2;
101 // }
102 // bb7: {
103 //     return;
104 // }
105 // bb8 (cleanup): {
106 //     resume;
107 // }
108 // END rustc.match_guard.CleanupNonCodegenStatements.after.mir