]> git.lizzy.rs Git - rust.git/blob - src/test/mir-opt/end_region_2.rs
Rollup merge of #52016 - oli-obk:dedup_static_errors, r=estebank
[rust.git] / src / test / mir-opt / end_region_2.rs
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
11 // compile-flags: -Z identify_regions -Z emit-end-regions
12 // ignore-tidy-linelength
13
14 // We will EndRegion for borrows in a loop that occur before break but
15 // not those after break.
16
17 fn main() {
18     loop {
19         let a = true;
20         let b = &a;
21         if a { break; }
22         let c = &a;
23     }
24 }
25
26 // END RUST SOURCE
27 // START rustc.main.SimplifyCfg-qualify-consts.after.mir
28 //     let mut _0: ();
29 //     ...
30 //     let _7: &'23_3rs bool;
31 //     ...
32 //     let _3: &'23_1rs bool;
33 //     ...
34 //     let _2: bool;
35 //     ...
36 //     let mut _4: ();
37 //     let mut _5: bool;
38 //     ...
39 //     bb0: {
40 //         goto -> bb1;
41 //     }
42 //     bb1: {
43 //          falseUnwind -> [real: bb2, cleanup: bb3];
44 //     }
45 //     bb2: {
46 //         StorageLive(_2);
47 //         _2 = const true;
48 //         StorageLive(_3);
49 //         _3 = &'23_1rs _2;
50 //         StorageLive(_5);
51 //         _5 = _2;
52 //         switchInt(move _5) -> [false: bb5, otherwise: bb4];
53 //     }
54 //     bb3: {
55 //         ...
56 //     }
57 //     bb4: {
58 //         _0 = ();
59 //         StorageDead(_5);
60 //         EndRegion('23_1rs);
61 //         StorageDead(_3);
62 //         StorageDead(_2);
63 //         return;
64 //     }
65 //     bb5: {
66 //         _4 = ();
67 //         StorageDead(_5);
68 //         StorageLive(_7);
69 //         _7 = &'23_3rs _2;
70 //         _1 = ();
71 //         EndRegion('23_3rs);
72 //         StorageDead(_7);
73 //         EndRegion('23_1rs);
74 //         StorageDead(_3);
75 //         StorageDead(_2);
76 //         goto -> bb1;
77 //     }
78 // END rustc.main.SimplifyCfg-qualify-consts.after.mir