]>
git.proxmox.com Git - rustc.git/blob - src/test/mir-opt/match_false_edges.rs
43e711ca902f89923a5cfb0bdb49cb0aa212f9f1
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 // _4 = &(promoted[1]: std::option::Option<i32>);
58 // _9 = discriminant(_2);
59 // switchInt(move _9) -> [0isize: bb5, 1isize: bb3, otherwise: bb7];
65 // _1 = (const 3i32, const 3i32);
68 // bb3: { // binding3(empty) and arm3
70 // falseEdges -> [real: bb8, imaginary: bb4]; //pre_binding1
74 // falseEdges -> [real: bb12, imaginary: bb5]; //pre_binding2
78 // falseEdges -> [real: bb2, imaginary: bb6]; //pre_binding3
86 // bb8: { // binding1 and guard
88 // _7 = &(((promoted[0]: std::option::Option<i32>) as Some).0: i32);
90 // _10 = const guard() -> [return: bb9, unwind: bb1];
93 // switchInt(move _10) -> [false: bb10, otherwise: bb11];
95 // bb10: { // to pre_binding2
96 // falseEdges -> [real: bb4, imaginary: bb4];
98 // bb11: { // bindingNoLandingPads.before.mir2 and arm2
100 // _5 = ((_2 as Some).0: i32);
103 // _1 = (const 1i32, move _11);
109 // _8 = ((_2 as Some).0: i32);
112 // _1 = (const 2i32, move_12);
120 // END rustc.full_tested_match.QualifyAndPromoteConstants.after.mir
122 // START rustc.full_tested_match2.QualifyAndPromoteConstants.before.mir
125 // _2 = std::option::Option<i32>::Some(const 42i32,);
126 // _3 = discriminant(_2);
128 // _9 = discriminant(_2);
129 // switchInt(move _9) -> [0isize: bb4, 1isize: bb3, otherwise: bb7];
135 // _1 = (const 3i32, const 3i32);
140 // falseEdges -> [real: bb8, imaginary: bb4]; //pre_binding1
144 // falseEdges -> [real: bb2, imaginary: bb5]; //pre_binding2
148 // falseEdges -> [real: bb12, imaginary: bb6]; //pre_binding3
156 // bb8: { // binding1 and guard
158 // _7 = &((_2 as Some).0: i32);
160 // _10 = const guard() -> [return: bb9, unwind: bb1];
162 // bb9: { // end of guard
163 // switchInt(move _10) -> [false: bb10, otherwise: bb11];
165 // bb10: { // to pre_binding3 (can skip 2 since this is `Some`)
166 // falseEdges -> [real: bb5, imaginary: bb4];
170 // _5 = ((_2 as Some).0: i32);
173 // _1 = (const 1i32, move _11);
177 // bb12: { // binding3 and arm3
179 // _8 = ((_2 as Some).0: i32);
182 // _1 = (const 2i32, move _12);
190 // END rustc.full_tested_match2.QualifyAndPromoteConstants.before.mir
192 // START rustc.main.QualifyAndPromoteConstants.before.mir
195 // _2 = std::option::Option<i32>::Some(const 1i32,);
196 // _3 = discriminant(_2);
198 // _13 = discriminant(_2);
199 // switchInt(move _13) -> [1isize: bb2, otherwise: bb3];
206 // falseEdges -> [real: bb7, imaginary: bb3]; //pre_binding1
210 // falseEdges -> [real: bb11, imaginary: bb4]; //pre_binding2
214 // falseEdges -> [real: bb12, imaginary: bb5]; //pre_binding3
218 // falseEdges -> [real: bb16, imaginary: bb6]; //pre_binding4
223 // bb7: { // binding1: Some(w) if guard()
225 // _7 = &((_2 as Some).0: i32);
227 // _14 = const guard() -> [return: bb8, unwind: bb1];
229 // bb8: { //end of guard
230 // switchInt(move _14) -> [false: bb9, otherwise: bb10];
232 // bb9: { // to pre_binding2
233 // falseEdges -> [real: bb3, imaginary: bb3];
235 // bb10: { // set up bindings for arm1
237 // _5 = ((_2 as Some).0: i32);
241 // bb11: { // binding2 & arm2
247 // bb12: { // binding3: Some(y) if guard2(y)
249 // _11 = &((_2 as Some).0: i32);
253 // _16 = const guard2(move _17) -> [return: bb13, unwind: bb1];
255 // bb13: { // end of guard2
257 // switchInt(move _16) -> [false: bb14, otherwise: bb15];
259 // bb14: { // to pre_binding4
260 // falseEdges -> [real: bb5, imaginary: bb5];
262 // bb15: { // set up bindings for arm3
264 // _9 = ((_2 as Some).0: i32);
268 // bb16: { // binding4 & arm4
278 // END rustc.main.QualifyAndPromoteConstants.before.mir