Skip to content

Commit 0f28009

Browse files
committed
add empty enum to the test cases
1 parent d6f8504 commit 0f28009

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/test/run-pass/panic-uninitialized-zeroed.rs

+20
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ struct Foo {
2020
y: !,
2121
}
2222

23+
enum Bar {}
24+
2325
fn main() {
2426
unsafe {
2527
assert_eq!(
@@ -57,5 +59,23 @@ fn main() {
5759
})),
5860
Some(true)
5961
);
62+
63+
assert_eq!(
64+
panic::catch_unwind(|| {
65+
mem::uninitialized::<Bar>()
66+
}).err().and_then(|a| a.downcast_ref::<String>().map(|s| {
67+
s == "Attempted to instantiate uninhabited type Bar using mem::uninitialized"
68+
})),
69+
Some(true)
70+
);
71+
72+
assert_eq!(
73+
panic::catch_unwind(|| {
74+
mem::zeroed::<Bar>()
75+
}).err().and_then(|a| a.downcast_ref::<String>().map(|s| {
76+
s == "Attempted to instantiate uninhabited type Bar using mem::zeroed"
77+
})),
78+
Some(true)
79+
);
6080
}
6181
}

0 commit comments

Comments
 (0)