add some tests specifically for validity checks arising from match binders
This commit is contained in:
parent
9b5b4dde92
commit
d17690065a
@ -0,0 +1,15 @@
|
||||
fn main() {
|
||||
#[derive(Copy, Clone)]
|
||||
enum Void {}
|
||||
union Uninit<T: Copy> {
|
||||
value: T,
|
||||
uninit: (),
|
||||
}
|
||||
unsafe {
|
||||
let x: Uninit<Void> = Uninit { uninit: () };
|
||||
match x.value {
|
||||
#[allow(unreachable_patterns)]
|
||||
_x => println!("hi from the void!"), //~ERROR: invalid value
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
error: Undefined Behavior: constructing invalid value: encountered a value of uninhabited type `main::Void`
|
||||
--> $DIR/match_binder_checks_validity1.rs:LL:CC
|
||||
|
|
||||
LL | _x => println!("hi from the void!"),
|
||||
| ^^ constructing invalid value: encountered a value of uninhabited type `main::Void`
|
||||
|
|
||||
= 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/match_binder_checks_validity1.rs:LL:CC
|
||||
|
||||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -0,0 +1,14 @@
|
||||
fn main() {
|
||||
#[derive(Copy, Clone)]
|
||||
union Uninit<T: Copy> {
|
||||
value: T,
|
||||
uninit: u8,
|
||||
}
|
||||
unsafe {
|
||||
let x: Uninit<bool> = Uninit { uninit: 3 };
|
||||
match x.value {
|
||||
#[allow(unreachable_patterns)]
|
||||
_x => println!("hi from the void!"), //~ERROR: invalid value
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
error: Undefined Behavior: constructing invalid value: encountered 0x03, but expected a boolean
|
||||
--> $DIR/match_binder_checks_validity2.rs:LL:CC
|
||||
|
|
||||
LL | _x => println!("hi from the void!"),
|
||||
| ^^ constructing invalid value: encountered 0x03, but expected a boolean
|
||||
|
|
||||
= 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/match_binder_checks_validity2.rs:LL:CC
|
||||
|
||||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
|
||||
|
||||
error: aborting due to previous error
|
||||
|
Loading…
x
Reference in New Issue
Block a user