Skip to content

Commit

Permalink
add empty enum to the test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
japaric authored and RalfJung committed Sep 30, 2018
1 parent 22cde0e commit 0bf40d8
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/test/run-pass/panic-uninitialized-zeroed.rs
Expand Up @@ -20,6 +20,8 @@ struct Foo {
y: !,
}

enum Bar {}

fn main() {
unsafe {
assert_eq!(
Expand Down Expand Up @@ -57,5 +59,23 @@ fn main() {
})),
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)
);
}
}

0 comments on commit 0bf40d8

Please sign in to comment.