]> git.lizzy.rs Git - rust.git/commitdiff
Add test to ensure const-prop fails gracefully
authorWesley Wiser <wwiser@gmail.com>
Wed, 15 May 2019 10:06:33 +0000 (06:06 -0400)
committerWesley Wiser <wwiser@gmail.com>
Wed, 15 May 2019 10:07:06 +0000 (06:07 -0400)
src/test/mir-opt/const_prop/const_prop_fails_gracefully.rs [new file with mode: 0644]

diff --git a/src/test/mir-opt/const_prop/const_prop_fails_gracefully.rs b/src/test/mir-opt/const_prop/const_prop_fails_gracefully.rs
new file mode 100644 (file)
index 0000000..97d3abd
--- /dev/null
@@ -0,0 +1,34 @@
+#[inline(never)]
+fn read(_: usize) { }
+
+fn main() {
+    const FOO: &i32 = &1;
+    let x = FOO as *const i32 as usize;
+    read(x);
+}
+
+// END RUST SOURCE
+// START rustc.main.ConstProp.before.mir
+//  bb0: {
+//      ...
+//      _3 = _4;
+//      _2 = move _3 as *const i32 (Misc);
+//      ...
+//      _1 = move _2 as usize (Misc);
+//      ...
+//      _6 = _1;
+//      _5 = const read(move _6) -> bb1;
+//  }
+// END rustc.main.ConstProp.before.mir
+// START rustc.main.ConstProp.after.mir
+//  bb0: {
+//      ...
+//      _3 = _4;
+//      _2 = move _3 as *const i32 (Misc);
+//      ...
+//      _1 = move _2 as usize (Misc);
+//      ...
+//      _6 = _1;
+//      _5 = const read(move _6) -> bb1;
+//  }
+// END rustc.main.ConstProp.after.mir