]> git.lizzy.rs Git - rust.git/blob - src/test/mir-opt/validate_3.rs
Auto merge of #53783 - RalfJung:ptr-docs, r=alexcrichton
[rust.git] / src / test / mir-opt / validate_3.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 // ignore-tidy-linelength
12 // compile-flags: -Z verbose -Z mir-emit-validate=1
13
14 struct Test {
15     x: i32
16 }
17
18 fn foo(_x: &i32) {}
19
20 fn main() {
21     // These internal unsafe functions should have no effect on the code generation.
22     unsafe fn _unused1() {}
23     fn _unused2(x: *const i32) -> i32 { unsafe { *x }}
24
25     let t = Test { x: 0 };
26     let t = &t;
27     foo(&t.x);
28 }
29
30 // END RUST SOURCE
31 // START rustc.main.EraseRegions.after.mir
32 // fn main() -> (){
33 //     let mut _0: ();
34 //     scope 1 {
35 //         scope 3 {
36 //         }
37 //         scope 4 {
38 //             let _2: &ReErased Test;
39 //         }
40 //     }
41 //     scope 2 {
42 //         let _1: Test;
43 //     }
44 //     let mut _3: ();
45 //     let mut _4: &ReErased i32;
46 //     let mut _5: &ReErased i32;
47 //     bb0: {
48 //         StorageLive(_1);
49 //         _1 = Test { x: const 0i32 };
50 //         FakeRead(ForLet, _1);
51 //         StorageLive(_2);
52 //         Validate(Suspend(ReScope(Remainder { block: ItemLocalId(20), first_statement_index: 3 })), [_1: Test]);
53 //         _2 = &ReErased _1;
54 //         Validate(Acquire, [(*_2): Test/ReScope(Remainder { block: ItemLocalId(20), first_statement_index: 3 }) (imm)]);
55 //         FakeRead(ForLet, _2);
56 //         StorageLive(_4);
57 //         StorageLive(_5);
58 //         Validate(Suspend(ReScope(Node(ItemLocalId(18)))), [((*_2).0: i32): i32/ReScope(Remainder { block: ItemLocalId(20), first_statement_index: 3 }) (imm)]);
59 //         _5 = &ReErased ((*_2).0: i32);
60 //         Validate(Acquire, [(*_5): i32/ReScope(Node(ItemLocalId(18))) (imm)]);
61 //         Validate(Suspend(ReScope(Node(ItemLocalId(18)))), [(*_5): i32/ReScope(Node(ItemLocalId(18))) (imm)]);
62 //         _4 = &ReErased (*_5);
63 //         Validate(Acquire, [(*_4): i32/ReScope(Node(ItemLocalId(18))) (imm)]);
64 //         Validate(Release, [_3: (), _4: &ReScope(Node(ItemLocalId(18))) i32]);
65 //         _3 = const foo(move _4) -> bb1;
66 //     }
67 //     bb1: {
68 //         Validate(Acquire, [_3: ()]);
69 //         EndRegion(ReScope(Node(ItemLocalId(18))));
70 //         StorageDead(_4);
71 //         StorageDead(_5);
72 //         _0 = ();
73 //         EndRegion(ReScope(Remainder { block: ItemLocalId(20), first_statement_index: 3 }));
74 //         StorageDead(_2);
75 //         StorageDead(_1);
76 //         return;
77 //     }
78 // }
79 // END rustc.main.EraseRegions.after.mir