From 758ce16b3dea3f08bfdacea75bcc55a8cd4ff106 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Thu, 23 Aug 2018 16:49:35 +0200 Subject: [PATCH] add empty enum to the test cases --- .../run-pass/panic-uninitialized-zeroed.rs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) 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::() + }).err().and_then(|a| a.downcast_ref::().map(|s| { + s == "Attempted to instantiate uninhabited type Bar using mem::uninitialized" + })), + Some(true) + ); + + assert_eq!( + panic::catch_unwind(|| { + mem::zeroed::() + }).err().and_then(|a| a.downcast_ref::().map(|s| { + s == "Attempted to instantiate uninhabited type Bar using mem::zeroed" + })), + Some(true) + ); } } -- 2.44.0