]> git.lizzy.rs Git - rust.git/blob - src/test/mir-opt/end_region_2.rs
Optimized error reporting for recursive requirements #47720
[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 _2: bool;
31 //     ...
32 //     let _3: &'23_1rs bool;
33 //     ...
34 //     let _7: &'23_3rs bool;
35 //     ...
36 //     let mut _4: ();
37 //     let mut _5: bool;
38 //     ...
39 //     bb0: {
40 //         goto -> bb1;
41 //     }
42 //     bb1: {
43 //         StorageLive(_2);
44 //         _2 = const true;
45 //         StorageLive(_3);
46 //         _3 = &'23_1rs _2;
47 //         StorageLive(_5);
48 //         _5 = _2;
49 //         switchInt(move _5) -> [0u8: bb3, otherwise: bb2];
50 //     }
51 //     bb2: {
52 //         _0 = ();
53 //         StorageDead(_5);
54 //         EndRegion('23_1rs);
55 //         StorageDead(_3);
56 //         StorageDead(_2);
57 //         return;
58 //     }
59 //     bb3: {
60 //         _4 = ();
61 //         StorageDead(_5);
62 //         StorageLive(_7);
63 //         _7 = &'23_3rs _2;
64 //         _1 = ();
65 //         EndRegion('23_3rs);
66 //         StorageDead(_7);
67 //         EndRegion('23_1rs);
68 //         StorageDead(_3);
69 //         StorageDead(_2);
70 //         goto -> bb1;
71 //     }
72 // END rustc.main.SimplifyCfg-qualify-consts.after.mir