Skip to content

Commit 4ed3d48

Browse files
committed
Auto merge of #1333 - RalfJung:flag-test, r=RalfJung
Make sure we find many failures even with other checks disabled
2 parents 0371590 + e6822d6 commit 4ed3d48

18 files changed

+48
-16
lines changed

tests/compile-fail/dangling_pointers/dangling_pointer_deref.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Make sure we find these even with many checks disabled.
2+
// compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation
3+
14
fn main() {
25
let p = {
36
let b = Box::new(42);

tests/compile-fail/dangling_pointers/dangling_zst_deref.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Make sure we find these even with many checks disabled.
2+
// compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation
3+
14
fn main() {
25
let p = {
36
let b = Box::new(42);

tests/compile-fail/uninit_uninhabited_type.rs renamed to tests/compile-fail/intrinsics/uninit_uninhabited_type.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// error-pattern: the evaluated program aborted execution: attempted to instantiate uninhabited type `!`
1+
// error-pattern: the evaluated program aborted execution: attempted to instantiate uninhabited type `!`
22
#![feature(never_type)]
33

44
#[allow(deprecated, invalid_value)]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// error-pattern: the evaluated program aborted execution: attempted to zero-initialize type `fn()`, which is invalid
2+
3+
#[allow(deprecated, invalid_value)]
4+
fn main() {
5+
unsafe { std::mem::zeroed::<fn()>() };
6+
}

tests/compile-fail/invalid_bool.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Validation makes this fail in the wrong place
2-
// compile-flags: -Zmiri-disable-validation
2+
// Make sure we find these even with many checks disabled.
3+
// compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation
34

45
fn main() {
56
let b = unsafe { std::mem::transmute::<u8, bool>(2) };

tests/compile-fail/invalid_char.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Validation makes this fail in the wrong place
2-
// compile-flags: -Zmiri-disable-validation
2+
// Make sure we find these even with many checks disabled.
3+
// compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation
34

45
fn main() {
56
assert!(std::char::from_u32(-1_i32 as u32).is_none());

tests/compile-fail/invalid_enum_discriminant.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Validation makes this fail in the wrong place
2-
// compile-flags: -Zmiri-disable-validation
2+
// Make sure we find these even with many checks disabled.
3+
// compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation
34

45
// error-pattern: invalid enum discriminant
56

tests/compile-fail/invalid_int.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Validation makes this fail in the wrong place
2+
// Make sure we find these even with many checks disabled.
3+
// compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation
4+
5+
fn main() {
6+
let i = unsafe { std::mem::MaybeUninit::<i32>::uninit().assume_init() };
7+
let _x = i + 0; //~ ERROR this operation requires initialized memory
8+
}

tests/compile-fail/invalid_zero_init.rs

Lines changed: 0 additions & 6 deletions
This file was deleted.

tests/compile-fail/overwriting_part_of_relocation_makes_the_rest_undefined.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Make sure we find these even with many checks disabled.
2+
// compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation
3+
14
fn main() {
25
let mut p = &42;
36
unsafe {

0 commit comments

Comments
 (0)