]> git.lizzy.rs Git - rust.git/blob - src/test/mir-opt/end_region_2.rs
Rollup merge of #45095 - bluss:discriminant-send-sync, 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.node4.SimplifyCfg-qualify-consts.after.mir
28 //     let mut _0: ();
29 //     let _2: bool;
30 //     let _3: &'23_1rs bool;
31 //     let _7: &'23_3rs bool;
32 //     let mut _4: ();
33 //     let mut _5: bool;
34 //     bb0: {
35 //         goto -> bb1;
36 //     }
37 //     bb1: {
38 //         StorageLive(_2);
39 //         _2 = const true;
40 //         StorageLive(_3);
41 //         _3 = &'23_1rs _2;
42 //         StorageLive(_5);
43 //         _5 = _2;
44 //         switchInt(_5) -> [0u8: bb3, otherwise: bb2];
45 //     }
46 //     bb2: {
47 //         _0 = ();
48 //         StorageDead(_5);
49 //         EndRegion('23_1rs);
50 //         StorageDead(_3);
51 //         StorageDead(_2);
52 //         return;
53 //     }
54 //     bb3: {
55 //         StorageDead(_5);
56 //         StorageLive(_7);
57 //         _7 = &'23_3rs _2;
58 //         _1 = ();
59 //         EndRegion('23_3rs);
60 //         StorageDead(_7);
61 //         EndRegion('23_1rs);
62 //         StorageDead(_3);
63 //         StorageDead(_2);
64 //         goto -> bb1;
65 //     }
66 // END rustc.node4.SimplifyCfg-qualify-consts.after.mir