1 // Copyright 2012-2016 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // compile-flags: -Z borrowck=mir
17 fn guard2(_:i32) -> bool {
21 // no_mangle to make sure this gets instantiated even in an executable.
23 pub fn full_tested_match() {
24 let _ = match Some(42) {
25 Some(x) if guard() => (1, x),
31 // no_mangle to make sure this gets instantiated even in an executable.
33 pub fn full_tested_match2() {
34 let _ = match Some(42) {
35 Some(x) if guard() => (1, x),
42 let _ = match Some(1) {
43 Some(_w) if guard() => 1,
45 Some(y) if guard2(y) => 3,
52 // START rustc.full_tested_match.QualifyAndPromoteConstants.after.mir
55 // _2 = std::option::Option<i32>::Some(const 42i32,);
56 // _3 = discriminant(_2);
57 // _6 = discriminant(_2);
58 // switchInt(move _6) -> [0isize: bb6, 1isize: bb4, otherwise: bb8];
66 // _1 = (const 1i32, move _8);
70 // bb3: { // binding3(empty) and arm3
71 // _1 = (const 3i32, const 3i32);
75 // falseEdges -> [real: bb9, imaginary: bb5]; //pre_binding1
78 // falseEdges -> [real: bb12, imaginary: bb6]; //pre_binding2
81 // falseEdges -> [real: bb3, imaginary: bb7]; //pre_binding3
89 // bb9: { // binding1 and guard
91 // _4 = ((_2 as Some).0: i32);
93 // _7 = const guard() -> [return: bb10, unwind: bb1];
95 // bb10: { // end of guard
96 // switchInt(move _7) -> [0u8: bb11, otherwise: bb2];
98 // bb11: { // to pre_binding2
99 // falseEdges -> [real: bb5, imaginary: bb5];
101 // bb12: { // bindingNoLandingPads.before.mir2 and arm2
103 // _5 = ((_2 as Some).0: i32);
106 // _1 = (const 2i32, move _9);
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 // _3 = discriminant(_2);
121 // _6 = discriminant(_2);
122 // switchInt(move _6) -> [0isize: bb5, 1isize: bb4, otherwise: bb8];
130 // _1 = (const 1i32, move _8);
134 // bb3: { // binding3(empty) and arm3
135 // _1 = (const 3i32, const 3i32);
139 // falseEdges -> [real: bb9, imaginary: bb5]; //pre_binding1
142 // falseEdges -> [real: bb3, imaginary: bb6]; //pre_binding2
145 // falseEdges -> [real: bb12, imaginary: bb7]; //pre_binding3
153 // bb9: { // binding1 and guard
155 // _4 = ((_2 as Some).0: i32);
157 // _7 = const guard() -> [return: bb10, unwind: bb1];
159 // bb10: { // end of guard
160 // switchInt(move _7) -> [0u8: bb11, otherwise: bb2];
162 // bb11: { // to pre_binding2
163 // falseEdges -> [real: bb6, imaginary: bb5];
165 // bb12: { // binding2 and arm2
167 // _5 = ((_2 as Some).0: i32);
170 // _1 = (const 2i32, move _9);
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 // _3 = discriminant(_2);
185 // _8 = discriminant(_2);
186 // switchInt(move _8) -> [1isize: bb4, otherwise: bb5];
201 // falseEdges -> [real: bb9, imaginary: bb5]; //pre_binding1
204 // falseEdges -> [real: bb12, imaginary: bb6]; //pre_binding2
207 // falseEdges -> [real: bb13, imaginary: bb7]; //pre_binding3
210 // falseEdges -> [real: bb16, imaginary: bb8]; //pre_binding4
215 // bb9: { // binding1: Some(w) if guard()
217 // _4 = ((_2 as Some).0: i32);
219 // _9 = const guard() -> [return: bb10, unwind: bb1];
221 // bb10: { //end of guard
222 // switchInt(move _9) -> [0u8: bb11, otherwise: bb2];
224 // bb11: { // to pre_binding2
225 // falseEdges -> [real: bb5, imaginary: bb5];
227 // bb12: { // binding2 & arm2
233 // bb13: { // binding3: Some(y) if guard2(y)
235 // _6 = ((_2 as Some).0: i32);
239 // _11 = const guard2(move _12) -> [return: bb14, unwind: bb1];
241 // bb14: { // end of guard2
243 // switchInt(move _11) -> [0u8: bb15, otherwise: bb3];
245 // bb15: { // to pre_binding4
246 // falseEdges -> [real: bb7, imaginary: bb7];
248 // bb16: { // binding4 & arm4
258 // END rustc.main.QualifyAndPromoteConstants.before.mir