]>
git.proxmox.com Git - rustc.git/blob - src/test/mir-opt/match_false_edges.rs
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);
59 // _9 = discriminant(_2);
60 // switchInt(move _9) -> [0isize: bb5, 1isize: bb3, otherwise: bb7];
66 // _1 = (const 3i32, const 3i32);
69 // bb3: { // binding3(empty) and arm3
71 // falseEdges -> [real: bb8, imaginary: bb4]; //pre_binding1
75 // falseEdges -> [real: bb12, imaginary: bb5]; //pre_binding2
79 // falseEdges -> [real: bb2, imaginary: bb6]; //pre_binding3
87 // bb8: { // binding1 and guard
90 // _7 = &(((*_13) as Some).0: i32);
92 // _10 = const guard() -> [return: bb9, unwind: bb1];
95 // switchInt(move _10) -> [false: bb10, otherwise: bb11];
97 // bb10: { // to pre_binding2
98 // falseEdges -> [real: bb4, imaginary: bb4];
100 // bb11: { // bindingNoLandingPads.before.mir2 and arm2
102 // _5 = ((_2 as Some).0: i32);
105 // _1 = (const 1i32, move _11);
111 // _8 = ((_2 as Some).0: i32);
114 // _1 = (const 2i32, move_12);
122 // END rustc.full_tested_match.QualifyAndPromoteConstants.after.mir
124 // START rustc.full_tested_match2.QualifyAndPromoteConstants.before.mir
127 // _2 = std::option::Option<i32>::Some(const 42i32,);
128 // _3 = discriminant(_2);
130 // _9 = discriminant(_2);
131 // switchInt(move _9) -> [0isize: bb4, 1isize: bb3, otherwise: bb7];
137 // _1 = (const 3i32, const 3i32);
142 // falseEdges -> [real: bb8, imaginary: bb4]; //pre_binding1
146 // falseEdges -> [real: bb2, imaginary: bb5]; //pre_binding2
150 // falseEdges -> [real: bb12, imaginary: bb6]; //pre_binding3
158 // bb8: { // binding1 and guard
160 // _7 = &((_2 as Some).0: i32);
162 // _10 = const guard() -> [return: bb9, unwind: bb1];
164 // bb9: { // end of guard
165 // switchInt(move _10) -> [false: bb10, otherwise: bb11];
167 // bb10: { // to pre_binding3 (can skip 2 since this is `Some`)
168 // falseEdges -> [real: bb5, imaginary: bb4];
172 // _5 = ((_2 as Some).0: i32);
175 // _1 = (const 1i32, move _11);
179 // bb12: { // binding3 and arm3
181 // _8 = ((_2 as Some).0: i32);
184 // _1 = (const 2i32, move _12);
192 // END rustc.full_tested_match2.QualifyAndPromoteConstants.before.mir
194 // START rustc.main.QualifyAndPromoteConstants.before.mir
197 // _2 = std::option::Option<i32>::Some(const 1i32,);
198 // _3 = discriminant(_2);
200 // _13 = discriminant(_2);
201 // switchInt(move _13) -> [1isize: bb2, otherwise: bb3];
208 // falseEdges -> [real: bb7, imaginary: bb3]; //pre_binding1
212 // falseEdges -> [real: bb11, imaginary: bb4]; //pre_binding2
216 // falseEdges -> [real: bb12, imaginary: bb5]; //pre_binding3
220 // falseEdges -> [real: bb16, imaginary: bb6]; //pre_binding4
225 // bb7: { // binding1: Some(w) if guard()
227 // _7 = &((_2 as Some).0: i32);
229 // _14 = const guard() -> [return: bb8, unwind: bb1];
231 // bb8: { //end of guard
232 // switchInt(move _14) -> [false: bb9, otherwise: bb10];
234 // bb9: { // to pre_binding2
235 // falseEdges -> [real: bb3, imaginary: bb3];
237 // bb10: { // set up bindings for arm1
239 // _5 = ((_2 as Some).0: i32);
243 // bb11: { // binding2 & arm2
249 // bb12: { // binding3: Some(y) if guard2(y)
251 // _11 = &((_2 as Some).0: i32);
255 // _16 = const guard2(move _17) -> [return: bb13, unwind: bb1];
257 // bb13: { // end of guard2
259 // switchInt(move _16) -> [false: bb14, otherwise: bb15];
261 // bb14: { // to pre_binding4
262 // falseEdges -> [real: bb5, imaginary: bb5];
264 // bb15: { // set up bindings for arm3
266 // _9 = ((_2 as Some).0: i32);
270 // bb16: { // binding4 & arm4
280 // END rustc.main.QualifyAndPromoteConstants.before.mir