]> git.lizzy.rs Git - rust.git/blob - src/test/mir-opt/const-promotion-extern-static.rs
Update const_forget.rs
[rust.git] / src / test / mir-opt / const-promotion-extern-static.rs
1 extern "C" {
2     static X: i32;
3 }
4
5 static Y: i32 = 42;
6
7 static mut BAR: *const &'static i32 = [&Y].as_ptr();
8
9 static mut FOO: *const &'static i32 = [unsafe { &X }].as_ptr();
10
11 fn main() {}
12
13 // END RUST SOURCE
14 // START rustc.FOO.PromoteTemps.before.mir
15 // bb0: {
16 // ...
17 //     _5 = const Scalar(alloc1+0) : &i32;
18 //     _4 = &(*_5);
19 //     _3 = [move _4];
20 //     _2 = &_3;
21 //     _1 = move _2 as &[&'static i32] (Pointer(Unsize));
22 //     _0 = const core::slice::<impl [&'static i32]>::as_ptr(move _1) -> [return: bb2, unwind: bb1];
23 // }
24 // ...
25 // bb2: {
26 //     StorageDead(_5);
27 //     StorageDead(_3);
28 //     return;
29 // }
30 // END rustc.FOO.PromoteTemps.before.mir
31 // START rustc.BAR.PromoteTemps.before.mir
32 // bb0: {
33 // ...
34 //     _5 = const Scalar(alloc0+0) : &i32;
35 //     _4 = &(*_5);
36 //     _3 = [move _4];
37 //     _2 = &_3;
38 //     _1 = move _2 as &[&'static i32] (Pointer(Unsize));
39 //     _0 = const core::slice::<impl [&'static i32]>::as_ptr(move _1) -> [return: bb2, unwind: bb1];
40 // }
41 // ...
42 // bb2: {
43 //     StorageDead(_5);
44 //     StorageDead(_3);
45 //     return;
46 // }
47 // END rustc.BAR.PromoteTemps.before.mir
48 // START rustc.BAR.PromoteTemps.after.mir
49 // bb0: {
50 // ...
51 //     _6 = const BAR::promoted[0];
52 //     _2 = &(*_6);
53 //     _1 = move _2 as &[&'static i32] (Pointer(Unsize));
54 //     _0 = const core::slice::<impl [&'static i32]>::as_ptr(move _1) -> [return: bb2, unwind: bb1];
55 // }
56 // ...
57 // bb2: {
58 //     return;
59 // }
60 // END rustc.BAR.PromoteTemps.after.mir
61 // START rustc.FOO.PromoteTemps.after.mir
62 // bb0: {
63 // ...
64 //     _6 = const FOO::promoted[0];
65 //     _2 = &(*_6);
66 //     _1 = move _2 as &[&'static i32] (Pointer(Unsize));
67 //     _0 = const core::slice::<impl [&'static i32]>::as_ptr(move _1) -> [return: bb2, unwind: bb1];
68 // }
69 // ...
70 // bb2: {
71 //     return;
72 // }
73 // END rustc.FOO.PromoteTemps.after.mir