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 // _3 = discriminant(_2);
48 // switchInt(move _3) -> [0isize: bb4, 1isize: bb2, otherwise: bb7];
54 // falseEdges -> [real: bb8, imaginary: bb3]; //pre_binding1
57 // falseEdges -> [real: bb11, imaginary: bb4]; //pre_binding2
60 // falseEdges -> [real: bb12, imaginary: bb5]; //pre_binding3
65 // bb6: { // to pre_binding2
66 // falseEdges -> [real: bb3, imaginary: bb3];
71 // bb8: { // binding1 and guard
73 // _6 = &(((promoted[1]: std::option::Option<i32>) as Some).0: i32);
74 // _4 = &shallow (promoted[0]: std::option::Option<i32>);
76 // _7 = const guard() -> [return: bb9, unwind: bb1];
79 // FakeRead(ForMatchGuard, _4);
80 // FakeRead(ForGuardBinding, _6);
81 // switchInt(move _7) -> [false: bb6, otherwise: bb10];
85 // _5 = ((_2 as Some).0: i32);
88 // _1 = (const 1i32, move _8);
94 // _9 = ((_2 as Some).0: i32);
97 // _1 = (const 2i32, move _10);
102 // _1 = (const 3i32, const 3i32);
109 // END rustc.full_tested_match.QualifyAndPromoteConstants.after.mir
111 // START rustc.full_tested_match2.QualifyAndPromoteConstants.before.mir
114 // _2 = std::option::Option::<i32>::Some(const 42i32,);
115 // FakeRead(ForMatchedPlace, _2);
116 // _3 = discriminant(_2);
117 // switchInt(move _3) -> [0isize: bb3, 1isize: bb2, otherwise: bb7];
123 // falseEdges -> [real: bb8, imaginary: bb3];
126 // falseEdges -> [real: bb11, imaginary: bb4];
129 // falseEdges -> [real: bb12, imaginary: bb5];
134 // bb6: { // to pre_binding3 (can skip 2 since this is `Some`)
135 // falseEdges -> [real: bb4, imaginary: bb3];
140 // bb8: { // binding1 and guard
142 // _6 = &((_2 as Some).0: i32);
145 // _7 = const guard() -> [return: bb9, unwind: bb1];
147 // bb9: { // end of guard
148 // FakeRead(ForMatchGuard, _4);
149 // FakeRead(ForGuardBinding, _6);
150 // switchInt(move _7) -> [false: bb6, otherwise: bb10];
154 // _5 = ((_2 as Some).0: i32);
157 // _1 = (const 1i32, move _8);
162 // _1 = (const 3i32, const 3i32);
165 // bb12: { // binding3 and arm3
167 // _9 = ((_2 as Some).0: i32);
170 // _1 = (const 2i32, move _10);
178 // END rustc.full_tested_match2.QualifyAndPromoteConstants.before.mir
180 // START rustc.main.QualifyAndPromoteConstants.before.mir
183 // _2 = std::option::Option::<i32>::Some(const 1i32,);
184 // FakeRead(ForMatchedPlace, _2);
185 // _3 = discriminant(_2);
186 // switchInt(move _3) -> [1isize: bb2, otherwise: bb3];
192 // falseEdges -> [real: bb9, imaginary: bb3];
195 // falseEdges -> [real: bb12, imaginary: bb4];
198 // falseEdges -> [real: bb13, imaginary: bb5];
201 // falseEdges -> [real: bb16, imaginary: bb6];
207 // falseEdges -> [real: bb3, imaginary: bb3];
210 // falseEdges -> [real: bb5, imaginary: bb5];
212 // bb9: { // binding1: Some(w) if guard()
214 // _7 = &((_2 as Some).0: i32);
217 // _8 = const guard() -> [return: bb10, unwind: bb1];
219 // bb10: { //end of guard
220 // FakeRead(ForMatchGuard, _5);
221 // FakeRead(ForGuardBinding, _7);
222 // switchInt(move _8) -> [false: bb7, otherwise: bb11];
224 // bb11: { // set up bindings for arm1
226 // _6 = ((_2 as Some).0: i32);
230 // bb12: { // binding2 & arm2
236 // bb13: { // binding3: Some(y) if guard2(y)
238 // _11 = &((_2 as Some).0: i32);
243 // _12 = const guard2(move _13) -> [return: bb14, unwind: bb1];
245 // bb14: { // end of guard2
247 // FakeRead(ForMatchGuard, _5);
248 // FakeRead(ForGuardBinding, _11);
249 // switchInt(move _12) -> [false: bb8, otherwise: bb15];
251 // bb15: { // binding4 & arm4
253 // _10 = ((_2 as Some).0: i32);
267 // END rustc.main.QualifyAndPromoteConstants.before.mir