about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2023-09-10 09:38:04 +0000
committerCamille GILLOT <gillot.camille@gmail.com>2023-10-24 15:30:17 +0000
commit3ec03f5d2f0f9e761b9b8732c00f87cbda111b9c (patch)
treecb65829815de7a30994f9a6435717aa785b9ab97
parent687659f33f388b8fe531362fa74891c1d14915de (diff)
downloadrust-3ec03f5d2f0f9e761b9b8732c00f87cbda111b9c.tar.gz
rust-3ec03f5d2f0f9e761b9b8732c00f87cbda111b9c.zip
Add miri test matching on `!`.
-rw-r--r--src/tools/miri/tests/fail/never_match_never.rs10
-rw-r--r--src/tools/miri/tests/fail/never_match_never.stderr15
2 files changed, 25 insertions, 0 deletions
diff --git a/src/tools/miri/tests/fail/never_match_never.rs b/src/tools/miri/tests/fail/never_match_never.rs
new file mode 100644
index 00000000000..5f2f471bf60
--- /dev/null
+++ b/src/tools/miri/tests/fail/never_match_never.rs
@@ -0,0 +1,10 @@
+// This should fail even without validation
+//@compile-flags: -Zmiri-disable-validation
+
+#![feature(never_type)]
+#![allow(unreachable_code)]
+
+fn main() {
+    let ptr: *const (i32, !) = &0i32 as *const i32 as *const _;
+    unsafe { match (*ptr).1 {} } //~ ERROR: entering unreachable code
+}
diff --git a/src/tools/miri/tests/fail/never_match_never.stderr b/src/tools/miri/tests/fail/never_match_never.stderr
new file mode 100644
index 00000000000..33dab81d5b0
--- /dev/null
+++ b/src/tools/miri/tests/fail/never_match_never.stderr
@@ -0,0 +1,15 @@
+error: Undefined Behavior: entering unreachable code
+  --> $DIR/never_match_never.rs:LL:CC
+   |
+LL |     unsafe { match (*ptr).1 {} }
+   |                    ^^^^^^^^ entering unreachable code
+   |
+   = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
+   = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
+   = note: BACKTRACE:
+   = note: inside `main` at $DIR/never_match_never.rs:LL:CC
+
+note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
+
+error: aborting due to previous error
+