2 // ignore-wasm32-bare always compiled as panic=abort right now and this requires unwinding
3 // This test checks that instantiating an uninhabited type via `mem::{uninitialized,zeroed}` results
6 #![feature(never_type)]
7 #![allow(deprecated, invalid_value)]
22 panic::catch_unwind(|| {
23 mem::uninitialized::<!>()
24 }).err().and_then(|a| a.downcast_ref::<String>().map(|s| {
25 s == "Attempted to instantiate uninhabited type !"
31 panic::catch_unwind(|| {
33 }).err().and_then(|a| a.downcast_ref::<String>().map(|s| {
34 s == "Attempted to instantiate uninhabited type !"
40 panic::catch_unwind(|| {
41 mem::MaybeUninit::<!>::uninit().assume_init()
42 }).err().and_then(|a| a.downcast_ref::<String>().map(|s| {
43 s == "Attempted to instantiate uninhabited type !"
49 panic::catch_unwind(|| {
50 mem::uninitialized::<Foo>()
51 }).err().and_then(|a| a.downcast_ref::<String>().map(|s| {
52 s == "Attempted to instantiate uninhabited type Foo"
58 panic::catch_unwind(|| {
60 }).err().and_then(|a| a.downcast_ref::<String>().map(|s| {
61 s == "Attempted to instantiate uninhabited type Foo"
67 panic::catch_unwind(|| {
68 mem::MaybeUninit::<Foo>::uninit().assume_init()
69 }).err().and_then(|a| a.downcast_ref::<String>().map(|s| {
70 s == "Attempted to instantiate uninhabited type Foo"
76 panic::catch_unwind(|| {
77 mem::uninitialized::<Bar>()
78 }).err().and_then(|a| a.downcast_ref::<String>().map(|s| {
79 s == "Attempted to instantiate uninhabited type Bar"
85 panic::catch_unwind(|| {
87 }).err().and_then(|a| a.downcast_ref::<String>().map(|s| {
88 s == "Attempted to instantiate uninhabited type Bar"
94 panic::catch_unwind(|| {
95 mem::MaybeUninit::<Bar>::uninit().assume_init()
96 }).err().and_then(|a| a.downcast_ref::<String>().map(|s| {
97 s == "Attempted to instantiate uninhabited type Bar"