Skip to content

Commit b17066d

Browse files
committed
Add test to ensure const-prop fails gracefully
1 parent 45214ed commit b17066d

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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

0 commit comments

Comments
 (0)