]>
Commit | Line | Data |
---|---|---|
041b39d2 XL |
1 | // Copyright 2017 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. | |
4 | // | |
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. | |
10 | ||
ea8adc8c | 11 | // compile-flags: -Z identify_regions -Z span_free_formats -Z emit-end-regions |
041b39d2 XL |
12 | // ignore-tidy-linelength |
13 | ||
14 | // This test models a scenario that arielb1 found during review. | |
15 | // Namely, any filtering of EndRegions must ensure to continue to emit | |
16 | // any necessary EndRegions that occur earlier in the source than the | |
17 | // first borrow involving that region. | |
18 | // | |
19 | // It is tricky to actually construct examples of this, which is the | |
20 | // main reason that I am keeping this test even though I have now | |
21 | // removed the pre-filter that motivated the test in the first place. | |
22 | ||
23 | fn main() { | |
24 | let mut second_iter = false; | |
25 | let x = 3; | |
26 | 'a: loop { | |
27 | let mut y; | |
28 | loop { | |
29 | if second_iter { | |
30 | break 'a; // want to generate `EndRegion('a)` here | |
31 | } else { | |
32 | y = &/*'a*/ x; | |
33 | } | |
34 | second_iter = true; | |
35 | } | |
36 | } | |
37 | } | |
38 | ||
39 | // END RUST SOURCE | |
abe05a73 | 40 | // START rustc.main.SimplifyCfg-qualify-consts.after.mir |
041b39d2 XL |
41 | // fn main() -> () { |
42 | // let mut _0: (); | |
abe05a73 | 43 | // ... |
94b46f34 | 44 | // let mut _4: &'33_0rs i32; |
abe05a73 | 45 | // ... |
041b39d2 | 46 | // let _2: i32; |
abe05a73 | 47 | // ... |
94b46f34 | 48 | // let mut _1: bool; |
abe05a73 | 49 | // ... |
041b39d2 XL |
50 | // let mut _3: (); |
51 | // let mut _5: !; | |
52 | // let mut _6: (); | |
53 | // let mut _7: bool; | |
54 | // let mut _8: !; | |
041b39d2 XL |
55 | // bb0: { |
56 | // StorageLive(_1); | |
57 | // _1 = const false; | |
58 | // StorageLive(_2); | |
59 | // _2 = const 3i32; | |
2c00a5a8 | 60 | // falseUnwind -> [real: bb2, cleanup: bb1]; |
041b39d2 | 61 | // } |
041b39d2 | 62 | // bb1: { |
2c00a5a8 XL |
63 | // ... |
64 | // } | |
65 | // bb2: { | |
66 | // StorageLive(_4); | |
67 | // goto -> bb3; | |
68 | // } | |
69 | // bb3: { | |
70 | // falseUnwind -> [real: bb4, cleanup: bb1]; | |
71 | // } | |
72 | // bb4: { | |
041b39d2 XL |
73 | // StorageLive(_7); |
74 | // _7 = _1; | |
0531ce1d | 75 | // switchInt(move _7) -> [false: bb6, otherwise: bb5]; |
041b39d2 | 76 | // } |
2c00a5a8 | 77 | // bb5: { |
041b39d2 XL |
78 | // _0 = (); |
79 | // StorageDead(_7); | |
ea8adc8c | 80 | // EndRegion('33_0rs); |
041b39d2 | 81 | // StorageDead(_4); |
041b39d2 XL |
82 | // StorageDead(_2); |
83 | // StorageDead(_1); | |
84 | // return; | |
85 | // } | |
2c00a5a8 | 86 | // bb6: { |
ea8adc8c | 87 | // _4 = &'33_0rs _2; |
041b39d2 XL |
88 | // _6 = (); |
89 | // StorageDead(_7); | |
90 | // _1 = const true; | |
91 | // _3 = (); | |
2c00a5a8 | 92 | // goto -> bb3; |
041b39d2 XL |
93 | // } |
94 | // } | |
abe05a73 | 95 | // END rustc.main.SimplifyCfg-qualify-consts.after.mir |