817adda794
Five of the files being skipped here are because rustfmt is buggy (see the error messages below). The others have clearly preferable manual formatting. error[internal]: left behind trailing whitespace --> tests/fail/validity/transmute_through_ptr.rs:18:18:1 | 18 | | ^^^^ | warning: rustfmt has failed to format. See previous 1 errors. error[internal]: left behind trailing whitespace --> tests/fail/stacked_borrows/illegal_read2.rs:10:10:1 | 10 | | ^^^^ | warning: rustfmt has failed to format. See previous 1 errors. error[internal]: left behind trailing whitespace --> tests/fail/stacked_borrows/illegal_read5.rs:15:15:1 | 15 | | ^^^^ | warning: rustfmt has failed to format. See previous 1 errors. error[internal]: left behind trailing whitespace --> tests/fail/stacked_borrows/illegal_read1.rs:10:10:1 | 10 | | ^^^^ | warning: rustfmt has failed to format. See previous 1 errors. error[internal]: left behind trailing whitespace --> tests/fail/erroneous_const2.rs:9:9:1 | 9 | | ^^^^ | warning: rustfmt has failed to format. See previous 1 errors.
18 lines
560 B
Rust
18 lines
560 B
Rust
#[repr(u32)]
|
|
#[derive(Debug)]
|
|
enum Bool { True }
|
|
|
|
fn evil(x: &mut Bool) {
|
|
let x = x as *mut _ as *mut u32;
|
|
unsafe { *x = 44; } // out-of-bounds enum tag
|
|
}
|
|
|
|
#[rustfmt::skip] // rustfmt bug: https://github.com/rust-lang/rustfmt/issues/5391
|
|
fn main() {
|
|
let mut x = Bool::True;
|
|
evil(&mut x);
|
|
let y = x; // reading this ought to be enough to trigger validation
|
|
//~^ ERROR type validation failed at .<enum-tag>: encountered 0x0000002c, but expected a valid enum tag
|
|
println!("{:?}", y); // make sure it is used (and not optimized away)
|
|
}
|