diff --git a/tests/compile-fail/dangling_pointers/dangling_pointer_deref.rs b/tests/compile-fail/dangling_pointers/dangling_pointer_deref.rs index f2c7ec584fef..e088a5532581 100644 --- a/tests/compile-fail/dangling_pointers/dangling_pointer_deref.rs +++ b/tests/compile-fail/dangling_pointers/dangling_pointer_deref.rs @@ -1,3 +1,6 @@ +// Make sure we find these even with many checks disabled. +// compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation + fn main() { let p = { let b = Box::new(42); diff --git a/tests/compile-fail/dangling_pointers/dangling_zst_deref.rs b/tests/compile-fail/dangling_pointers/dangling_zst_deref.rs index 13e5f9d32173..f1b5149dabb4 100644 --- a/tests/compile-fail/dangling_pointers/dangling_zst_deref.rs +++ b/tests/compile-fail/dangling_pointers/dangling_zst_deref.rs @@ -1,3 +1,6 @@ +// Make sure we find these even with many checks disabled. +// compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation + fn main() { let p = { let b = Box::new(42); diff --git a/tests/compile-fail/uninit_uninhabited_type.rs b/tests/compile-fail/intrinsics/uninit_uninhabited_type.rs similarity index 53% rename from tests/compile-fail/uninit_uninhabited_type.rs rename to tests/compile-fail/intrinsics/uninit_uninhabited_type.rs index b9048830783f..deb3586c781e 100644 --- a/tests/compile-fail/uninit_uninhabited_type.rs +++ b/tests/compile-fail/intrinsics/uninit_uninhabited_type.rs @@ -1,4 +1,4 @@ - // error-pattern: the evaluated program aborted execution: attempted to instantiate uninhabited type `!` +// error-pattern: the evaluated program aborted execution: attempted to instantiate uninhabited type `!` #![feature(never_type)] #[allow(deprecated, invalid_value)] diff --git a/tests/compile-fail/intrinsics/zero_fn_ptr.rs b/tests/compile-fail/intrinsics/zero_fn_ptr.rs new file mode 100644 index 000000000000..81dbf6c429b3 --- /dev/null +++ b/tests/compile-fail/intrinsics/zero_fn_ptr.rs @@ -0,0 +1,6 @@ +// error-pattern: the evaluated program aborted execution: attempted to zero-initialize type `fn()`, which is invalid + +#[allow(deprecated, invalid_value)] +fn main() { + unsafe { std::mem::zeroed::() }; +} diff --git a/tests/compile-fail/invalid_bool.rs b/tests/compile-fail/invalid_bool.rs index 6ccea3531636..38033146ade8 100644 --- a/tests/compile-fail/invalid_bool.rs +++ b/tests/compile-fail/invalid_bool.rs @@ -1,5 +1,6 @@ // Validation makes this fail in the wrong place -// compile-flags: -Zmiri-disable-validation +// Make sure we find these even with many checks disabled. +// compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation fn main() { let b = unsafe { std::mem::transmute::(2) }; diff --git a/tests/compile-fail/invalid_char.rs b/tests/compile-fail/invalid_char.rs index ed61fcbe9d52..ab10ab1e2173 100644 --- a/tests/compile-fail/invalid_char.rs +++ b/tests/compile-fail/invalid_char.rs @@ -1,5 +1,6 @@ // Validation makes this fail in the wrong place -// compile-flags: -Zmiri-disable-validation +// Make sure we find these even with many checks disabled. +// compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation fn main() { assert!(std::char::from_u32(-1_i32 as u32).is_none()); diff --git a/tests/compile-fail/invalid_enum_discriminant.rs b/tests/compile-fail/invalid_enum_discriminant.rs index c1b8727c129b..cdbea6aa1223 100644 --- a/tests/compile-fail/invalid_enum_discriminant.rs +++ b/tests/compile-fail/invalid_enum_discriminant.rs @@ -1,5 +1,6 @@ // Validation makes this fail in the wrong place -// compile-flags: -Zmiri-disable-validation +// Make sure we find these even with many checks disabled. +// compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation // error-pattern: invalid enum discriminant diff --git a/tests/compile-fail/invalid_int.rs b/tests/compile-fail/invalid_int.rs new file mode 100644 index 000000000000..26a85802079b --- /dev/null +++ b/tests/compile-fail/invalid_int.rs @@ -0,0 +1,8 @@ +// Validation makes this fail in the wrong place +// Make sure we find these even with many checks disabled. +// compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation + +fn main() { + let i = unsafe { std::mem::MaybeUninit::::uninit().assume_init() }; + let _x = i + 0; //~ ERROR this operation requires initialized memory +} diff --git a/tests/compile-fail/invalid_zero_init.rs b/tests/compile-fail/invalid_zero_init.rs deleted file mode 100644 index 78c2b0fbeeb7..000000000000 --- a/tests/compile-fail/invalid_zero_init.rs +++ /dev/null @@ -1,6 +0,0 @@ - // error-pattern: the evaluated program aborted execution: attempted to zero-initialize type `fn()`, which is invalid - -#[allow(deprecated, invalid_value)] -fn main() { - unsafe { std::mem::zeroed::() }; -} diff --git a/tests/compile-fail/overwriting_part_of_relocation_makes_the_rest_undefined.rs b/tests/compile-fail/overwriting_part_of_relocation_makes_the_rest_undefined.rs index d8182aaae662..3eab4c0f3d5e 100644 --- a/tests/compile-fail/overwriting_part_of_relocation_makes_the_rest_undefined.rs +++ b/tests/compile-fail/overwriting_part_of_relocation_makes_the_rest_undefined.rs @@ -1,3 +1,6 @@ +// Make sure we find these even with many checks disabled. +// compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation + fn main() { let mut p = &42; unsafe { diff --git a/tests/compile-fail/stacked_borrows/load_invalid_mut.rs b/tests/compile-fail/stacked_borrows/load_invalid_mut.rs index 1704b7fe19b2..c2c4ce6726df 100644 --- a/tests/compile-fail/stacked_borrows/load_invalid_mut.rs +++ b/tests/compile-fail/stacked_borrows/load_invalid_mut.rs @@ -1,3 +1,6 @@ +// Make sure we catch this even without validation +// compile-flags: -Zmiri-disable-validation + // Make sure that we cannot load from memory a `&mut` that got already invalidated. fn main() { let x = &mut 42; diff --git a/tests/compile-fail/stacked_borrows/load_invalid_shr.rs b/tests/compile-fail/stacked_borrows/load_invalid_shr.rs index 4757a2c1e589..7d681f649a10 100644 --- a/tests/compile-fail/stacked_borrows/load_invalid_shr.rs +++ b/tests/compile-fail/stacked_borrows/load_invalid_shr.rs @@ -1,3 +1,6 @@ +// Make sure we catch this even without validation +// compile-flags: -Zmiri-disable-validation + // Make sure that we cannot load from memory a `&` that got already invalidated. fn main() { let x = &mut 42; diff --git a/tests/compile-fail/unaligned_pointers/unaligned_ptr1.rs b/tests/compile-fail/unaligned_pointers/unaligned_ptr1.rs index ee1a13004231..0a67cfc5a1b3 100644 --- a/tests/compile-fail/unaligned_pointers/unaligned_ptr1.rs +++ b/tests/compile-fail/unaligned_pointers/unaligned_ptr1.rs @@ -1,5 +1,5 @@ -// This should fail even without validation -// compile-flags: -Zmiri-disable-validation +// This should fail even without validation or Stacked Borrows. +// compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows fn main() { let x = [2u16, 3, 4]; // Make it big enough so we don't get an out-of-bounds error. diff --git a/tests/compile-fail/unaligned_pointers/unaligned_ptr2.rs b/tests/compile-fail/unaligned_pointers/unaligned_ptr2.rs index 853d890ecf07..b1fb2f4aa976 100644 --- a/tests/compile-fail/unaligned_pointers/unaligned_ptr2.rs +++ b/tests/compile-fail/unaligned_pointers/unaligned_ptr2.rs @@ -1,5 +1,5 @@ -// This should fail even without validation. -// compile-flags: -Zmiri-disable-validation +// This should fail even without validation or Stacked Borrows. +// compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows fn main() { let x = [2u32, 3]; // Make it big enough so we don't get an out-of-bounds error. diff --git a/tests/compile-fail/unaligned_pointers/unaligned_ptr3.rs b/tests/compile-fail/unaligned_pointers/unaligned_ptr3.rs index 43f6b472da05..c5a3398384e4 100644 --- a/tests/compile-fail/unaligned_pointers/unaligned_ptr3.rs +++ b/tests/compile-fail/unaligned_pointers/unaligned_ptr3.rs @@ -1,5 +1,5 @@ -// This should fail even without validation. -// compile-flags: -Zmiri-disable-validation +// This should fail even without validation or Stacked Borrows. +// compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows fn main() { let x = [2u16, 3, 4, 5]; // Make it big enough so we don't get an out-of-bounds error. diff --git a/tests/compile-fail/validity/dangling_ref1.rs b/tests/compile-fail/validity/dangling_ref1.rs index 034510f3b283..a83c6af21acf 100644 --- a/tests/compile-fail/validity/dangling_ref1.rs +++ b/tests/compile-fail/validity/dangling_ref1.rs @@ -1,3 +1,5 @@ +// Make sure we catch this even without Stacked Borrows +// compile-flags: -Zmiri-disable-stacked-borrows use std::mem; fn main() { diff --git a/tests/compile-fail/validity/dangling_ref2.rs b/tests/compile-fail/validity/dangling_ref2.rs index 4ad9b8135db4..7aff1a49785c 100644 --- a/tests/compile-fail/validity/dangling_ref2.rs +++ b/tests/compile-fail/validity/dangling_ref2.rs @@ -1,3 +1,5 @@ +// Make sure we catch this even without Stacked Borrows +// compile-flags: -Zmiri-disable-stacked-borrows use std::mem; fn main() { diff --git a/tests/compile-fail/validity/dangling_ref3.rs b/tests/compile-fail/validity/dangling_ref3.rs index 46e17375a828..495a266a85dc 100644 --- a/tests/compile-fail/validity/dangling_ref3.rs +++ b/tests/compile-fail/validity/dangling_ref3.rs @@ -1,3 +1,5 @@ +// Make sure we catch this even without Stacked Borrows +// compile-flags: -Zmiri-disable-stacked-borrows use std::mem; fn dangling() -> *const u8 {