]> git.proxmox.com Git - rustc.git/blame - src/test/mir-opt/end_region_2.rs
New upstream version 1.28.0~beta.14+dfsg1
[rustc.git] / src / test / mir-opt / end_region_2.rs
CommitLineData
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 emit-end-regions
041b39d2
XL
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
17fn 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
abe05a73 27// START rustc.main.SimplifyCfg-qualify-consts.after.mir
041b39d2 28// let mut _0: ();
abe05a73 29// ...
94b46f34 30// let _7: &'23_3rs bool;
abe05a73 31// ...
ea8adc8c 32// let _3: &'23_1rs bool;
abe05a73 33// ...
94b46f34 34// let _2: bool;
abe05a73 35// ...
041b39d2
XL
36// let mut _4: ();
37// let mut _5: bool;
abe05a73 38// ...
041b39d2
XL
39// bb0: {
40// goto -> bb1;
41// }
42// bb1: {
2c00a5a8
XL
43// falseUnwind -> [real: bb2, cleanup: bb3];
44// }
45// bb2: {
041b39d2
XL
46// StorageLive(_2);
47// _2 = const true;
48// StorageLive(_3);
ea8adc8c 49// _3 = &'23_1rs _2;
041b39d2
XL
50// StorageLive(_5);
51// _5 = _2;
0531ce1d 52// switchInt(move _5) -> [false: bb5, otherwise: bb4];
041b39d2 53// }
2c00a5a8
XL
54// bb3: {
55// ...
56// }
57// bb4: {
041b39d2
XL
58// _0 = ();
59// StorageDead(_5);
ea8adc8c 60// EndRegion('23_1rs);
041b39d2 61// StorageDead(_3);
041b39d2
XL
62// StorageDead(_2);
63// return;
64// }
2c00a5a8 65// bb5: {
abe05a73 66// _4 = ();
041b39d2
XL
67// StorageDead(_5);
68// StorageLive(_7);
ea8adc8c 69// _7 = &'23_3rs _2;
041b39d2 70// _1 = ();
ea8adc8c 71// EndRegion('23_3rs);
041b39d2 72// StorageDead(_7);
ea8adc8c 73// EndRegion('23_1rs);
041b39d2 74// StorageDead(_3);
041b39d2
XL
75// StorageDead(_2);
76// goto -> bb1;
77// }
abe05a73 78// END rustc.main.SimplifyCfg-qualify-consts.after.mir