diff options
| author | Jorge Aparicio <jorge@japaric.io> | 2018-08-23 16:49:35 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2018-09-30 17:27:06 +0200 |
| commit | 0bf40d86d8e93cc6d7a11419d5fb2d6d7e5fa2b0 (patch) | |
| tree | 0f0216c116f31629cb9aa88e709cf8af33492975 /src/test/run-pass | |
| parent | 22cde0efa5c95d740ab04d7d47e3f1be55725cd8 (diff) | |
| download | rust-0bf40d86d8e93cc6d7a11419d5fb2d6d7e5fa2b0.tar.gz rust-0bf40d86d8e93cc6d7a11419d5fb2d6d7e5fa2b0.zip | |
add empty enum to the test cases
Diffstat (limited to 'src/test/run-pass')
| -rw-r--r-- | src/test/run-pass/panic-uninitialized-zeroed.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/test/run-pass/panic-uninitialized-zeroed.rs b/src/test/run-pass/panic-uninitialized-zeroed.rs index fd88bba49c4..f40ea7cce07 100644 --- a/src/test/run-pass/panic-uninitialized-zeroed.rs +++ b/src/test/run-pass/panic-uninitialized-zeroed.rs @@ -20,6 +20,8 @@ struct Foo { y: !, } +enum Bar {} + fn main() { unsafe { assert_eq!( @@ -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) + ); } } |
