]> git.lizzy.rs Git - rust.git/blob - src/test/mir-opt/const_prop/const_prop_fails_gracefully.rs
Add test to ensure const-prop fails gracefully
[rust.git] / src / test / mir-opt / const_prop / const_prop_fails_gracefully.rs
1 #[inline(never)]
2 fn read(_: usize) { }
3
4 fn main() {
5     const FOO: &i32 = &1;
6     let x = FOO as *const i32 as usize;
7     read(x);
8 }
9
10 // END RUST SOURCE
11 // START rustc.main.ConstProp.before.mir
12 //  bb0: {
13 //      ...
14 //      _3 = _4;
15 //      _2 = move _3 as *const i32 (Misc);
16 //      ...
17 //      _1 = move _2 as usize (Misc);
18 //      ...
19 //      _6 = _1;
20 //      _5 = const read(move _6) -> bb1;
21 //  }
22 // END rustc.main.ConstProp.before.mir
23 // START rustc.main.ConstProp.after.mir
24 //  bb0: {
25 //      ...
26 //      _3 = _4;
27 //      _2 = move _3 as *const i32 (Misc);
28 //      ...
29 //      _1 = move _2 as usize (Misc);
30 //      ...
31 //      _6 = _1;
32 //      _5 = const read(move _6) -> bb1;
33 //  }
34 // END rustc.main.ConstProp.after.mir