make sure our disable flags do not miss all bugs; move type-assert intrinsic tests to their folder

This commit is contained in:
Ralf Jung 2020-04-14 09:58:58 +02:00
parent 03715907f4
commit 179e78d0ad
10 changed files with 30 additions and 10 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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)]

View File

@ -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::<fn()>() };
}

View File

@ -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::<u8, bool>(2) };

View File

@ -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());

View File

@ -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

View File

@ -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::<i32>::uninit().assume_init() };
let _x = i + 0; //~ ERROR this operation requires initialized memory
}

View File

@ -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::<fn()>() };
}

View File

@ -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 {