diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2023-09-10 09:38:04 +0000 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2023-10-24 15:30:17 +0000 |
| commit | 3ec03f5d2f0f9e761b9b8732c00f87cbda111b9c (patch) | |
| tree | cb65829815de7a30994f9a6435717aa785b9ab97 | |
| parent | 687659f33f388b8fe531362fa74891c1d14915de (diff) | |
| download | rust-3ec03f5d2f0f9e761b9b8732c00f87cbda111b9c.tar.gz rust-3ec03f5d2f0f9e761b9b8732c00f87cbda111b9c.zip | |
Add miri test matching on `!`.
| -rw-r--r-- | src/tools/miri/tests/fail/never_match_never.rs | 10 | ||||
| -rw-r--r-- | src/tools/miri/tests/fail/never_match_never.stderr | 15 |
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 + |
