]> git.proxmox.com Git - rustc.git/blob - src/test/mir-opt/end_region_4.rs
New upstream version 1.23.0+dfsg1
[rustc.git] / src / test / mir-opt / end_region_4.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 // Unwinding should EndRegion for in-scope borrows: Direct borrows.
15
16 fn main() {
17 let d = D(0);
18 let a = 0;
19 let b = &a;
20 foo(*b);
21 let c = &a;
22 }
23
24 struct D(i32);
25 impl Drop for D { fn drop(&mut self) { println!("dropping D({})", self.0); } }
26
27 fn foo(i: i32) {
28 if i > 0 { panic!("im positive"); }
29 }
30
31 // END RUST SOURCE
32 // START rustc.main.SimplifyCfg-qualify-consts.after.mir
33 // let mut _0: ();
34 // ...
35 // let _1: D;
36 // ...
37 // let _2: i32;
38 // ...
39 // let _3: &'26_2rs i32;
40 // ...
41 // let _6: &'26_4rs i32;
42 // ...
43 // let mut _4: ();
44 // let mut _5: i32;
45 // bb0: {
46 // StorageLive(_1);
47 // _1 = D::{{constructor}}(const 0i32,);
48 // StorageLive(_2);
49 // _2 = const 0i32;
50 // StorageLive(_3);
51 // _3 = &'26_2rs _2;
52 // StorageLive(_5);
53 // _5 = (*_3);
54 // _4 = const foo(_5) -> [return: bb1, unwind: bb3];
55 // }
56 // bb1: {
57 // StorageDead(_5);
58 // StorageLive(_6);
59 // _6 = &'26_4rs _2;
60 // _0 = ();
61 // EndRegion('26_4rs);
62 // StorageDead(_6);
63 // EndRegion('26_2rs);
64 // StorageDead(_3);
65 // StorageDead(_2);
66 // drop(_1) -> bb4;
67 // }
68 // bb2: {
69 // resume;
70 // }
71 // bb3: {
72 // EndRegion('26_2rs);
73 // drop(_1) -> bb2;
74 // }
75 // bb4: {
76 // StorageDead(_1);
77 // return;
78 // }
79 // END rustc.main.SimplifyCfg-qualify-consts.after.mir