account for mir-opts masking more errors

This commit is contained in:
Ralf Jung 2020-09-20 12:02:04 +02:00
parent 83a339e5a9
commit 08e076c658
2 changed files with 5 additions and 3 deletions

@ -1,5 +1,5 @@
// This should fail even without validation
// compile-flags: -Zmiri-disable-validation
// This should fail even without validation, but some MIR opts mask the error
// compile-flags: -Zmiri-disable-validation -Zmir-opt-level=0
static mut LEAK: usize = 0;

@ -1,4 +1,5 @@
#[repr(u32)]
#[derive(Debug)]
enum Bool { True }
fn evil(x: &mut Bool) {
@ -9,6 +10,7 @@ fn evil(x: &mut Bool) {
fn main() {
let mut x = Bool::True;
evil(&mut x);
let _y = x; // reading this ought to be enough to trigger validation
let y = x; // reading this ought to be enough to trigger validation
//~^ ERROR encountered 0x0000002c at .<enum-tag>, but expected a valid enum tag
println!("{:?}", y); // make sure it is used (and not optimized away)
}