1 #![feature(never_type)]
4 pub enum UninhabitedEnum {
8 pub struct UninhabitedTupleStruct(!);
11 pub struct UninhabitedStruct {
15 pub enum UninhabitedVariants {
16 #[non_exhaustive] Tuple(!),
17 #[non_exhaustive] Struct { x: ! }
22 // This test checks that uninhabited non-exhaustive types defined in the same crate cannot coerce
23 // to any type, as the never type can.
25 fn can_coerce_never_type_to_anything(x: !) -> A {
29 fn cannot_coerce_empty_enum_to_anything(x: UninhabitedEnum) -> A {
30 x //~ ERROR mismatched types
33 fn cannot_coerce_empty_tuple_struct_to_anything(x: UninhabitedTupleStruct) -> A {
34 x //~ ERROR mismatched types
37 fn cannot_coerce_empty_struct_to_anything(x: UninhabitedStruct) -> A {
38 x //~ ERROR mismatched types
41 fn cannot_coerce_enum_with_empty_variants_to_anything(x: UninhabitedVariants) -> A {
42 x //~ ERROR mismatched types