1 // compile-flags: -Z borrowck=mir
7 fn guard2(_:i32) -> bool {
11 // no_mangle to make sure this gets instantiated even in an executable.
13 pub fn full_tested_match() {
14 let _ = match Some(42) {
15 Some(x) if guard() => (1, x),
21 // no_mangle to make sure this gets instantiated even in an executable.
23 pub fn full_tested_match2() {
24 let _ = match Some(42) {
25 Some(x) if guard() => (1, x),
32 let _ = match Some(1) {
33 Some(_w) if guard() => 1,
35 Some(y) if guard2(y) => 3,
42 // START rustc.full_tested_match.QualifyAndPromoteConstants.after.mir
45 // _2 = std::option::Option<i32>::Some(const 42i32,);
46 // FakeRead(ForMatchedPlace, _2);
47 // _7 = discriminant(_2);
48 // _9 = &shallow (promoted[2]: std::option::Option<i32>);
49 // _10 = &(((promoted[1]: std::option::Option<i32>) as Some).0: i32);
50 // switchInt(move _7) -> [0isize: bb5, 1isize: bb3, otherwise: bb7];
56 // _1 = (const 3i32, const 3i32);
59 // bb3: { // binding3(empty) and arm3
60 // FakeRead(ForMatchGuard, _9);
61 // FakeRead(ForMatchGuard, _10);
62 // falseEdges -> [real: bb8, imaginary: bb4]; //pre_binding1
65 // FakeRead(ForMatchGuard, _9);
66 // FakeRead(ForMatchGuard, _10);
67 // falseEdges -> [real: bb12, imaginary: bb5]; //pre_binding2
70 // FakeRead(ForMatchGuard, _9);
71 // FakeRead(ForMatchGuard, _10);
72 // falseEdges -> [real: bb2, imaginary: bb6]; //pre_binding3
80 // bb8: { // binding1 and guard
82 // _5 = &(((promoted[0]: std::option::Option<i32>) as Some).0: i32);
84 // _8 = const guard() -> [return: bb9, unwind: bb1];
87 // switchInt(move _8) -> [false: bb10, otherwise: bb11];
89 // bb10: { // to pre_binding2
90 // falseEdges -> [real: bb4, imaginary: bb4];
92 // bb11: { // bindingNoLandingPads.before.mir2 and arm2
94 // _3 = ((_2 as Some).0: i32);
97 // _1 = (const 1i32, move _11);
103 // _6 = ((_2 as Some).0: i32);
106 // _1 = (const 2i32, move_12);
114 // END rustc.full_tested_match.QualifyAndPromoteConstants.after.mir
116 // START rustc.full_tested_match2.QualifyAndPromoteConstants.before.mir
119 // _2 = std::option::Option<i32>::Some(const 42i32,);
120 // FakeRead(ForMatchedPlace, _2);
121 // _7 = discriminant(_2);
123 // _10 = &((_2 as Some).0: i32);
124 // switchInt(move _7) -> [0isize: bb4, 1isize: bb3, otherwise: bb7];
130 // _1 = (const 3i32, const 3i32);
134 // FakeRead(ForMatchGuard, _9);
135 // FakeRead(ForMatchGuard, _10);
136 // falseEdges -> [real: bb8, imaginary: bb4]; //pre_binding1
139 // FakeRead(ForMatchGuard, _9);
140 // FakeRead(ForMatchGuard, _10);
141 // falseEdges -> [real: bb2, imaginary: bb5]; //pre_binding2
144 // FakeRead(ForMatchGuard, _9);
145 // FakeRead(ForMatchGuard, _10);
146 // falseEdges -> [real: bb12, imaginary: bb6]; //pre_binding3
154 // bb8: { // binding1 and guard
156 // _5 = &((_2 as Some).0: i32);
158 // _8 = const guard() -> [return: bb9, unwind: bb1];
160 // bb9: { // end of guard
161 // switchInt(move _8) -> [false: bb10, otherwise: bb11];
163 // bb10: { // to pre_binding3 (can skip 2 since this is `Some`)
164 // falseEdges -> [real: bb5, imaginary: bb4];
168 // _3 = ((_2 as Some).0: i32);
171 // _1 = (const 1i32, move _11);
175 // bb12: { // binding3 and arm3
177 // _6 = ((_2 as Some).0: i32);
180 // _1 = (const 2i32, move _12);
188 // END rustc.full_tested_match2.QualifyAndPromoteConstants.before.mir
190 // START rustc.main.QualifyAndPromoteConstants.before.mir
193 // _2 = std::option::Option<i32>::Some(const 1i32,);
194 // FakeRead(ForMatchedPlace, _2);
195 // _11 = discriminant(_2);
196 // _16 = &shallow _2;
197 // _17 = &((_2 as Some).0: i32);
198 // switchInt(move _11) -> [1isize: bb2, otherwise: bb3];
204 // FakeRead(ForMatchGuard, _16);
205 // FakeRead(ForMatchGuard, _17);
206 // falseEdges -> [real: bb7, imaginary: bb3]; //pre_binding1
209 // FakeRead(ForMatchGuard, _16);
210 // FakeRead(ForMatchGuard, _17);
211 // falseEdges -> [real: bb11, imaginary: bb4]; //pre_binding2
214 // FakeRead(ForMatchGuard, _16);
215 // FakeRead(ForMatchGuard, _17);
216 // falseEdges -> [real: bb12, imaginary: bb5]; //pre_binding3
219 // FakeRead(ForMatchGuard, _16);
220 // FakeRead(ForMatchGuard, _17);
221 // falseEdges -> [real: bb16, imaginary: bb6]; //pre_binding4
226 // bb7: { // binding1: Some(w) if guard()
228 // _5 = &((_2 as Some).0: i32);
230 // _12 = const guard() -> [return: bb8, unwind: bb1];
232 // bb8: { //end of guard
233 // switchInt(move _12) -> [false: bb9, otherwise: bb10];
235 // bb9: { // to pre_binding2
236 // falseEdges -> [real: bb3, imaginary: bb3];
238 // bb10: { // set up bindings for arm1
240 // _3 = ((_2 as Some).0: i32);
244 // bb11: { // binding2 & arm2
250 // bb12: { // binding3: Some(y) if guard2(y)
252 // _9 = &((_2 as Some).0: i32);
256 // _14 = const guard2(move _15) -> [return: bb13, unwind: bb1];
258 // bb13: { // end of guard2
260 // switchInt(move _14) -> [false: bb14, otherwise: bb15];
262 // bb14: { // to pre_binding4
263 // falseEdges -> [real: bb5, imaginary: bb5];
265 // bb15: { // set up bindings for arm3
267 // _7 = ((_2 as Some).0: i32);
271 // bb16: { // binding4 & arm4
281 // END rustc.main.QualifyAndPromoteConstants.before.mir