about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-06-04 12:37:44 +0000
committerbors <bors@rust-lang.org>2019-06-04 12:37:44 +0000
commitacda261de83475cf6cbc607d570153bb864ee7be (patch)
tree7427c87553a743736a80a9c423090836a8766651 /src/test
parent021a5033098ff0e3f7126acc7ac35149d325f16d (diff)
parentb2536781afd0eaef11f6b2f68924dde380cf18f2 (diff)
downloadrust-acda261de83475cf6cbc607d570153bb864ee7be.tar.gz
rust-acda261de83475cf6cbc607d570153bb864ee7be.zip
Auto merge of #61437 - christianpoveda:const-eval-indirects, r=wesleywiser,oli-obk
Add const-eval support for indirects

r? @wesleywiser
Diffstat (limited to 'src/test')
-rw-r--r--src/test/mir-opt/const_prop/const_prop_fails_gracefully.rs5
-rw-r--r--src/test/mir-opt/const_prop/indirect.rs23
2 files changed, 26 insertions, 2 deletions
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
index 97d3abdcc6c..85ed8d55b24 100644
--- a/src/test/mir-opt/const_prop/const_prop_fails_gracefully.rs
+++ b/src/test/mir-opt/const_prop/const_prop_fails_gracefully.rs
@@ -23,8 +23,9 @@ fn main() {
 // START rustc.main.ConstProp.after.mir
 //  bb0: {
 //      ...
-//      _3 = _4;
-//      _2 = move _3 as *const i32 (Misc);
+//      _4 = const Scalar(AllocId(1).0x0) : &i32;
+//      _3 = const Scalar(AllocId(1).0x0) : &i32;
+//      _2 = const Scalar(AllocId(1).0x0) : *const i32;
 //      ...
 //      _1 = move _2 as usize (Misc);
 //      ...
diff --git a/src/test/mir-opt/const_prop/indirect.rs b/src/test/mir-opt/const_prop/indirect.rs
new file mode 100644
index 00000000000..b4ee18ed1b5
--- /dev/null
+++ b/src/test/mir-opt/const_prop/indirect.rs
@@ -0,0 +1,23 @@
+// compile-flags: -C overflow-checks=on
+
+fn main() {
+    let x = (2u32 as u8) + 1;
+}
+
+// END RUST SOURCE
+// START rustc.main.ConstProp.before.mir
+// bb0: {
+//     ...
+//     _2 = const 2u32 as u8 (Misc);
+//     _3 = CheckedAdd(move _2, const 1u8);
+//     assert(!move (_3.1: bool), "attempt to add with overflow") -> bb1;
+//}
+// END rustc.main.ConstProp.before.mir
+// START rustc.main.ConstProp.after.mir
+// bb0: {
+//     ...
+//     _2 = const 2u8;
+//     _3 = (const 3u8, const false);
+//     assert(!const false, "attempt to add with overflow") -> bb1;
+// }
+// END rustc.main.ConstProp.after.mir