Skip to content

Commit 90908b8

Browse files
committed
also test some things to not panic
1 parent d5d44f7 commit 90908b8

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/test/ui/intrinsics/panic-uninitialized-zeroed.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ struct Foo {
1717

1818
enum Bar {}
1919

20+
#[allow(dead_code)]
21+
enum OneVariant { Variant(i32) }
22+
2023
fn test_panic_msg<T>(op: impl (FnOnce() -> T) + panic::UnwindSafe, msg: &str) {
2124
let err = panic::catch_unwind(op).err();
2225
assert_eq!(
@@ -94,5 +97,10 @@ fn main() {
9497
|| mem::zeroed::<(NonNull<u32>, u32, u32)>(),
9598
"attempted to zero-initialize non-zero type `(std::ptr::NonNull<u32>, u32, u32)`"
9699
);
100+
101+
// Some things that should work.
102+
let _val = mem::zeroed::<bool>();
103+
let _val = mem::zeroed::<OneVariant>();
104+
let _val = mem::zeroed::<Option<&'static i32>>();
97105
}
98106
}

0 commit comments

Comments
 (0)