]> git.lizzy.rs Git - rust.git/commitdiff
add empty enum to the test cases
authorJorge Aparicio <jorge@japaric.io>
Thu, 23 Aug 2018 14:49:35 +0000 (16:49 +0200)
committerJorge Aparicio <jorge@japaric.io>
Sat, 22 Sep 2018 19:01:21 +0000 (21:01 +0200)
src/test/run-pass/panic-uninitialized-zeroed.rs

index fd88bba49c4846e8fb2a853ce0d6af6928a691d2..f40ea7cce078aeb2decbed6d32af0d47373d717c 100644 (file)
@@ -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)
+        );
     }
 }