Skip to content

Commit 3ec03f5

Browse files
committed
Add miri test matching on !.
1 parent 687659f commit 3ec03f5

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

Diff for: src/tools/miri/tests/fail/never_match_never.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// This should fail even without validation
2+
//@compile-flags: -Zmiri-disable-validation
3+
4+
#![feature(never_type)]
5+
#![allow(unreachable_code)]
6+
7+
fn main() {
8+
let ptr: *const (i32, !) = &0i32 as *const i32 as *const _;
9+
unsafe { match (*ptr).1 {} } //~ ERROR: entering unreachable code
10+
}

Diff for: src/tools/miri/tests/fail/never_match_never.stderr

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error: Undefined Behavior: entering unreachable code
2+
--> $DIR/never_match_never.rs:LL:CC
3+
|
4+
LL | unsafe { match (*ptr).1 {} }
5+
| ^^^^^^^^ entering unreachable code
6+
|
7+
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
8+
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
9+
= note: BACKTRACE:
10+
= note: inside `main` at $DIR/never_match_never.rs:LL:CC
11+
12+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
13+
14+
error: aborting due to previous error
15+

0 commit comments

Comments
 (0)