Skip to content

Commit 0826899

Browse files
committed
Remove uninhabit/zeroed tests to a new test file for abort checking
1 parent 52e1372 commit 0826899

File tree

4 files changed

+15
-55
lines changed

4 files changed

+15
-55
lines changed
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+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// error-pattern: the evaluated program aborted execution: attempted to instantiate uninhabited type `!`
2+
#![feature(never_type)]
3+
4+
#[allow(deprecated, invalid_value)]
5+
fn main() {
6+
unsafe { std::mem::uninitialized::<!>() };
7+
}

tests/run-pass/panic/catch_panic.rs

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -67,43 +67,6 @@ fn main() {
6767
|_old_val| { let _val = 1/0; loop {} },
6868
);
6969

70-
// libcore panics from shims.
71-
#[allow(deprecated, invalid_value)]
72-
{
73-
test(
74-
Some("attempted to instantiate uninhabited type `!`"),
75-
|_old_val| unsafe { std::mem::uninitialized::<!>() },
76-
);
77-
test(
78-
Some("attempted to instantiate uninhabited type `!`"),
79-
|_old_val| unsafe { std::mem::zeroed::<!>() },
80-
);
81-
test(
82-
Some("attempted to leave type `fn()` uninitialized, which is invalid"),
83-
|_old_val| unsafe { std::mem::uninitialized::<fn()>(); loop {} },
84-
);
85-
test(
86-
Some("attempted to zero-initialize type `fn()`, which is invalid"),
87-
|_old_val| unsafe { std::mem::zeroed::<fn()>(); loop {} },
88-
);
89-
test(
90-
Some("attempted to leave type `*const dyn std::marker::Sync` uninitialized, which is invalid"),
91-
|_old_val| unsafe { std::mem::uninitialized::<*const dyn Sync>(); loop {} },
92-
);
93-
test(
94-
Some("attempted to zero-initialize type `*mut dyn std::marker::Sync`, which is invalid"),
95-
|_old_val| unsafe { std::mem::zeroed::<*mut dyn Sync>(); loop {} },
96-
);
97-
test(
98-
Some("attempted to leave type `&u8` uninitialized, which is invalid"),
99-
|_old_val| unsafe { std::mem::uninitialized::<&u8>(); loop {} },
100-
);
101-
test(
102-
Some("attempted to zero-initialize type `&u8`, which is invalid"),
103-
|_old_val| unsafe { std::mem::zeroed::<&u8>(); loop {} },
104-
);
105-
}
106-
10770
test(
10871
Some("align_offset: align is not a power-of-two"),
10972
|_old_val| { (0usize as *const u8).align_offset(3); loop {} },

tests/run-pass/panic/catch_panic.stderr

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,11 @@ thread 'main' panicked at 'index out of bounds: the len is 3 but the index is 4'
1616
Caught panic message (String): index out of bounds: the len is 3 but the index is 4
1717
thread 'main' panicked at 'attempt to divide by zero', $DIR/catch_panic.rs:67:33
1818
Caught panic message (String): attempt to divide by zero
19-
thread 'main' panicked at 'attempted to instantiate uninhabited type `!`', $LOC
20-
Caught panic message (String): attempted to instantiate uninhabited type `!`
21-
thread 'main' panicked at 'attempted to instantiate uninhabited type `!`', $LOC
22-
Caught panic message (String): attempted to instantiate uninhabited type `!`
23-
thread 'main' panicked at 'attempted to leave type `fn()` uninitialized, which is invalid', $LOC
24-
Caught panic message (String): attempted to leave type `fn()` uninitialized, which is invalid
25-
thread 'main' panicked at 'attempted to zero-initialize type `fn()`, which is invalid', $LOC
26-
Caught panic message (String): attempted to zero-initialize type `fn()`, which is invalid
27-
thread 'main' panicked at 'attempted to leave type `*const dyn std::marker::Sync` uninitialized, which is invalid', $LOC
28-
Caught panic message (String): attempted to leave type `*const dyn std::marker::Sync` uninitialized, which is invalid
29-
thread 'main' panicked at 'attempted to zero-initialize type `*mut dyn std::marker::Sync`, which is invalid', $LOC
30-
Caught panic message (String): attempted to zero-initialize type `*mut dyn std::marker::Sync`, which is invalid
31-
thread 'main' panicked at 'attempted to leave type `&u8` uninitialized, which is invalid', $LOC
32-
Caught panic message (String): attempted to leave type `&u8` uninitialized, which is invalid
33-
thread 'main' panicked at 'attempted to zero-initialize type `&u8`, which is invalid', $LOC
34-
Caught panic message (String): attempted to zero-initialize type `&u8`, which is invalid
3519
thread 'main' panicked at 'align_offset: align is not a power-of-two', $LOC
3620
Caught panic message (String): align_offset: align is not a power-of-two
37-
thread 'main' panicked at 'assertion failed: false', $DIR/catch_panic.rs:113:29
21+
thread 'main' panicked at 'assertion failed: false', $DIR/catch_panic.rs:76:29
3822
Caught panic message (&str): assertion failed: false
39-
thread 'main' panicked at 'assertion failed: false', $DIR/catch_panic.rs:114:29
23+
thread 'main' panicked at 'assertion failed: false', $DIR/catch_panic.rs:77:29
4024
Caught panic message (&str): assertion failed: false
4125
thread 'main' panicked at 'attempt to copy from unaligned or null pointer', $LOC
4226
Caught panic message (String): attempt to copy from unaligned or null pointer

0 commit comments

Comments
 (0)