about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorJorge Aparicio <jorge@japaric.io>2018-08-23 16:49:35 +0200
committerJorge Aparicio <jorge@japaric.io>2018-09-22 21:01:21 +0200
commit758ce16b3dea3f08bfdacea75bcc55a8cd4ff106 (patch)
tree2298257500cbeae5abd99dd20017d81c24b115d0 /src/test
parentd864edc349f2548d9b05c7fa99f1387946e18f8b (diff)
downloadrust-758ce16b3dea3f08bfdacea75bcc55a8cd4ff106.tar.gz
rust-758ce16b3dea3f08bfdacea75bcc55a8cd4ff106.zip
add empty enum to the test cases
Diffstat (limited to 'src/test')
-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)
+        );
     }
 }