1 // ignore-wasm32-bare always compiled as panic=abort right now and this requires unwinding
2 // This test checks that instantiating an uninhabited type via `mem::{uninitialized,zeroed}` results
5 #![feature(never_type)]
20 panic::catch_unwind(|| {
21 mem::uninitialized::<!>()
22 }).err().and_then(|a| a.downcast_ref::<String>().map(|s| {
23 s == "Attempted to instantiate uninhabited type !"
29 panic::catch_unwind(|| {
31 }).err().and_then(|a| a.downcast_ref::<String>().map(|s| {
32 s == "Attempted to instantiate uninhabited type !"
38 panic::catch_unwind(|| {
39 mem::MaybeUninit::<!>::uninit().assume_init()
40 }).err().and_then(|a| a.downcast_ref::<String>().map(|s| {
41 s == "Attempted to instantiate uninhabited type !"
47 panic::catch_unwind(|| {
48 mem::uninitialized::<Foo>()
49 }).err().and_then(|a| a.downcast_ref::<String>().map(|s| {
50 s == "Attempted to instantiate uninhabited type Foo"
56 panic::catch_unwind(|| {
58 }).err().and_then(|a| a.downcast_ref::<String>().map(|s| {
59 s == "Attempted to instantiate uninhabited type Foo"
65 panic::catch_unwind(|| {
66 mem::MaybeUninit::<Foo>::uninit().assume_init()
67 }).err().and_then(|a| a.downcast_ref::<String>().map(|s| {
68 s == "Attempted to instantiate uninhabited type Foo"
74 panic::catch_unwind(|| {
75 mem::uninitialized::<Bar>()
76 }).err().and_then(|a| a.downcast_ref::<String>().map(|s| {
77 s == "Attempted to instantiate uninhabited type Bar"
83 panic::catch_unwind(|| {
85 }).err().and_then(|a| a.downcast_ref::<String>().map(|s| {
86 s == "Attempted to instantiate uninhabited type Bar"
92 panic::catch_unwind(|| {
93 mem::MaybeUninit::<Bar>::uninit().assume_init()
94 }).err().and_then(|a| a.downcast_ref::<String>().map(|s| {
95 s == "Attempted to instantiate uninhabited type Bar"