Remove uninhabit/zeroed tests to a new test file for abort checking

This commit is contained in:
Elichai Turkel 2020-03-18 13:18:08 +02:00
parent 52e1372e03
commit 0826899ca0
No known key found for this signature in database
GPG key ID: 9383CDE9E8E66A7F
4 changed files with 15 additions and 55 deletions

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

@ -0,0 +1,7 @@
// error-pattern: the evaluated program aborted execution: attempted to instantiate uninhabited type `!`
#![feature(never_type)]
#[allow(deprecated, invalid_value)]
fn main() {
unsafe { std::mem::uninitialized::<!>() };
}

View file

@ -67,43 +67,6 @@ fn main() {
|_old_val| { let _val = 1/0; loop {} },
);
// libcore panics from shims.
#[allow(deprecated, invalid_value)]
{
test(
Some("attempted to instantiate uninhabited type `!`"),
|_old_val| unsafe { std::mem::uninitialized::<!>() },
);
test(
Some("attempted to instantiate uninhabited type `!`"),
|_old_val| unsafe { std::mem::zeroed::<!>() },
);
test(
Some("attempted to leave type `fn()` uninitialized, which is invalid"),
|_old_val| unsafe { std::mem::uninitialized::<fn()>(); loop {} },
);
test(
Some("attempted to zero-initialize type `fn()`, which is invalid"),
|_old_val| unsafe { std::mem::zeroed::<fn()>(); loop {} },
);
test(
Some("attempted to leave type `*const dyn std::marker::Sync` uninitialized, which is invalid"),
|_old_val| unsafe { std::mem::uninitialized::<*const dyn Sync>(); loop {} },
);
test(
Some("attempted to zero-initialize type `*mut dyn std::marker::Sync`, which is invalid"),
|_old_val| unsafe { std::mem::zeroed::<*mut dyn Sync>(); loop {} },
);
test(
Some("attempted to leave type `&u8` uninitialized, which is invalid"),
|_old_val| unsafe { std::mem::uninitialized::<&u8>(); loop {} },
);
test(
Some("attempted to zero-initialize type `&u8`, which is invalid"),
|_old_val| unsafe { std::mem::zeroed::<&u8>(); loop {} },
);
}
test(
Some("align_offset: align is not a power-of-two"),
|_old_val| { (0usize as *const u8).align_offset(3); loop {} },

View file

@ -16,27 +16,11 @@ thread 'main' panicked at 'index out of bounds: the len is 3 but the index is 4'
Caught panic message (String): index out of bounds: the len is 3 but the index is 4
thread 'main' panicked at 'attempt to divide by zero', $DIR/catch_panic.rs:67:33
Caught panic message (String): attempt to divide by zero
thread 'main' panicked at 'attempted to instantiate uninhabited type `!`', $LOC
Caught panic message (String): attempted to instantiate uninhabited type `!`
thread 'main' panicked at 'attempted to instantiate uninhabited type `!`', $LOC
Caught panic message (String): attempted to instantiate uninhabited type `!`
thread 'main' panicked at 'attempted to leave type `fn()` uninitialized, which is invalid', $LOC
Caught panic message (String): attempted to leave type `fn()` uninitialized, which is invalid
thread 'main' panicked at 'attempted to zero-initialize type `fn()`, which is invalid', $LOC
Caught panic message (String): attempted to zero-initialize type `fn()`, which is invalid
thread 'main' panicked at 'attempted to leave type `*const dyn std::marker::Sync` uninitialized, which is invalid', $LOC
Caught panic message (String): attempted to leave type `*const dyn std::marker::Sync` uninitialized, which is invalid
thread 'main' panicked at 'attempted to zero-initialize type `*mut dyn std::marker::Sync`, which is invalid', $LOC
Caught panic message (String): attempted to zero-initialize type `*mut dyn std::marker::Sync`, which is invalid
thread 'main' panicked at 'attempted to leave type `&u8` uninitialized, which is invalid', $LOC
Caught panic message (String): attempted to leave type `&u8` uninitialized, which is invalid
thread 'main' panicked at 'attempted to zero-initialize type `&u8`, which is invalid', $LOC
Caught panic message (String): attempted to zero-initialize type `&u8`, which is invalid
thread 'main' panicked at 'align_offset: align is not a power-of-two', $LOC
Caught panic message (String): align_offset: align is not a power-of-two
thread 'main' panicked at 'assertion failed: false', $DIR/catch_panic.rs:113:29
thread 'main' panicked at 'assertion failed: false', $DIR/catch_panic.rs:76:29
Caught panic message (&str): assertion failed: false
thread 'main' panicked at 'assertion failed: false', $DIR/catch_panic.rs:114:29
thread 'main' panicked at 'assertion failed: false', $DIR/catch_panic.rs:77:29
Caught panic message (&str): assertion failed: false
thread 'main' panicked at 'attempt to copy from unaligned or null pointer', $LOC
Caught panic message (String): attempt to copy from unaligned or null pointer