]> git.lizzy.rs Git - rust.git/blob - src/test/mir-opt/end_region_4.rs
Fix tests and assertions; add some comments
[rust.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 _6: &'31_4rs i32;
36 //     ...
37 //     let _3: &'31_2rs i32;
38 //     ...
39 //     let _2: i32;
40 //     ...
41 //     let _1: D;
42 //     ...
43 //     let mut _4: ();
44 //     let mut _5: i32;
45 //     bb0: {
46 //         StorageLive(_1);
47 //         _1 = D::{{constructor}}(const 0i32,);
48 //         FakeRead(ForLet, _1);
49 //         StorageLive(_2);
50 //         _2 = const 0i32;
51 //         FakeRead(ForLet, _2);
52 //         StorageLive(_3);
53 //         _3 = &'31_2rs _2;
54 //         FakeRead(ForLet, _3);
55 //         StorageLive(_5);
56 //         _5 = (*_3);
57 //         _4 = const foo(move _5) -> [return: bb2, unwind: bb3];
58 //     }
59 //     bb1: {
60 //         resume;
61 //     }
62 //     bb2: {
63 //         StorageDead(_5);
64 //         StorageLive(_6);
65 //         _6 = &'31_4rs _2;
66 //         FakeRead(ForLet, _6);
67 //         _0 = ();
68 //         EndRegion('31_4rs);
69 //         StorageDead(_6);
70 //         EndRegion('31_2rs);
71 //         StorageDead(_3);
72 //         StorageDead(_2);
73 //         drop(_1) -> [return: bb4, unwind: bb1];
74 //     }
75 //     bb3: {
76 //         EndRegion('31_2rs);
77 //         drop(_1) -> bb1;
78 //     }
79 //     bb4: {
80 //         StorageDead(_1);
81 //         return;
82 //     }
83 // END rustc.main.SimplifyCfg-qualify-consts.after.mir