about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-04-18 09:55:39 +0000
committerbors <bors@rust-lang.org>2024-04-18 09:55:39 +0000
commit5c9924a599bb9f04ca8d0d8760b1be52d77fb3fa (patch)
treeebf7acefbb165233da38dd3d44eddfd770c77322
parent5697f731b4aecf418b79212b78055994df62d66e (diff)
parent5ef38aca35b7fd2645d82abfb8ab740e9fd01972 (diff)
downloadrust-5c9924a599bb9f04ca8d0d8760b1be52d77fb3fa.tar.gz
rust-5c9924a599bb9f04ca8d0d8760b1be52d77fb3fa.zip
Auto merge of #3486 - RalfJung:mir-validate, r=RalfJung
add test checking that we do run MIR validation

Fixes https://github.com/rust-lang/miri/issues/2840
-rw-r--r--src/tools/miri/tests/panic/mir-validation.rs21
-rw-r--r--src/tools/miri/tests/panic/mir-validation.stderr21
2 files changed, 42 insertions, 0 deletions
diff --git a/src/tools/miri/tests/panic/mir-validation.rs b/src/tools/miri/tests/panic/mir-validation.rs
new file mode 100644
index 00000000000..5e207c26096
--- /dev/null
+++ b/src/tools/miri/tests/panic/mir-validation.rs
@@ -0,0 +1,21 @@
+//! Ensure that the MIR validator runs on Miri's input.
+//@normalize-stderr-test: "\n +[0-9]+:[^\n]+" -> ""
+//@normalize-stderr-test: "\n +at [^\n]+" -> ""
+//@normalize-stderr-test: "\n +\[\.\.\. omitted [0-9]+ frames? \.\.\.\]" -> ""
+//@normalize-stderr-test: "\n[ =]*note:.*" -> ""
+#![feature(custom_mir, core_intrinsics)]
+use core::intrinsics::mir::*;
+
+#[custom_mir(dialect = "runtime", phase = "optimized")]
+pub fn main() {
+    mir! {
+        let x: i32;
+        let tuple: (*mut i32,);
+        {
+            tuple.0 = core::ptr::addr_of_mut!(x);
+            // Deref at the wrong place!
+            *(tuple.0) = 1;
+            Return()
+        }
+    }
+}
diff --git a/src/tools/miri/tests/panic/mir-validation.stderr b/src/tools/miri/tests/panic/mir-validation.stderr
new file mode 100644
index 00000000000..243fed020e7
--- /dev/null
+++ b/src/tools/miri/tests/panic/mir-validation.stderr
@@ -0,0 +1,21 @@
+thread 'rustc' panicked at compiler/rustc_const_eval/src/transform/validate.rs:LL:CC:
+broken MIR in Item(DefId(0:4 ~ mir_validation[fad2]::main)) (after phase change to runtime-optimized) at bb0[1]:
+(*(_2.0: *mut i32)), has deref at the wrong place
+stack backtrace:
+
+error: the compiler unexpectedly panicked. this is a bug.
+
+
+
+
+query stack during panic:
+#0 [optimized_mir] optimizing MIR for `main`
+end of query stack
+
+Miri caused an ICE during evaluation. Here's the interpreter backtrace at the time of the panic:
+  --> RUSTLIB/core/src/ops/function.rs:LL:CC
+   |
+LL |     extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+