add empty enum to the test cases

This commit is contained in:
Jorge Aparicio
2018-08-23 16:49:35 +02:00
parent d864edc349
commit 758ce16b3d

View File

@@ -20,6 +20,8 @@ struct Foo {
y: !, y: !,
} }
enum Bar {}
fn main() { fn main() {
unsafe { unsafe {
assert_eq!( assert_eq!(
@@ -57,5 +59,23 @@ fn main() {
})), })),
Some(true) Some(true)
); );
assert_eq!(
panic::catch_unwind(|| {
mem::uninitialized::<Bar>()
}).err().and_then(|a| a.downcast_ref::<String>().map(|s| {
s == "Attempted to instantiate uninhabited type Bar using mem::uninitialized"
})),
Some(true)
);
assert_eq!(
panic::catch_unwind(|| {
mem::zeroed::<Bar>()
}).err().and_then(|a| a.downcast_ref::<String>().map(|s| {
s == "Attempted to instantiate uninhabited type Bar using mem::zeroed"
})),
Some(true)
);
} }
} }