]> git.lizzy.rs Git - rust.git/blob - src/test/mir-opt/end_region_2.rs
Auto merge of #53783 - RalfJung:ptr-docs, r=alexcrichton
[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 //         FakeRead(ForLet, _2);
49 //         StorageLive(_3);
50 //         _3 = &'23_1rs _2;
51 //         FakeRead(ForLet, _3);
52 //         StorageLive(_5);
53 //         _5 = _2;
54 //         switchInt(move _5) -> [false: bb5, otherwise: bb4];
55 //     }
56 //     bb3: {
57 //         ...
58 //     }
59 //     bb4: {
60 //         _0 = ();
61 //         StorageDead(_5);
62 //         EndRegion('23_1rs);
63 //         StorageDead(_3);
64 //         StorageDead(_2);
65 //         return;
66 //     }
67 //     bb5: {
68 //         _4 = ();
69 //         StorageDead(_5);
70 //         StorageLive(_7);
71 //         _7 = &'23_3rs _2;
72 //         FakeRead(ForLet, _7);
73 //         _1 = ();
74 //         EndRegion('23_3rs);
75 //         StorageDead(_7);
76 //         EndRegion('23_1rs);
77 //         StorageDead(_3);
78 //         StorageDead(_2);
79 //         goto -> bb1;
80 //     }
81 // END rustc.main.SimplifyCfg-qualify-consts.after.mir