about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorJorge Aparicio <jorge@japaric.io>2018-08-23 16:49:35 +0200
committerRalf Jung <post@ralfj.de>2018-09-30 17:27:06 +0200
commit0bf40d86d8e93cc6d7a11419d5fb2d6d7e5fa2b0 (patch)
tree0f0216c116f31629cb9aa88e709cf8af33492975 /src
parent22cde0efa5c95d740ab04d7d47e3f1be55725cd8 (diff)
downloadrust-0bf40d86d8e93cc6d7a11419d5fb2d6d7e5fa2b0.tar.gz
rust-0bf40d86d8e93cc6d7a11419d5fb2d6d7e5fa2b0.zip
add empty enum to the test cases
Diffstat (limited to 'src')
-rw-r--r--src/test/run-pass/panic-uninitialized-zeroed.rs20
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)
+        );
     }
 }