3 #![deny(unreachable_patterns)]
4 #![feature(exhaustive_patterns)]
5 #![feature(never_type)]
6 #![feature(non_exhaustive)]
9 pub enum UninhabitedEnum {
13 pub struct UninhabitedStruct {
18 pub struct UninhabitedTupleStruct(!);
20 pub enum UninhabitedVariants {
21 #[non_exhaustive] Tuple(!),
22 #[non_exhaustive] Struct { x: ! }
25 pub struct IndirectUninhabitedEnum(UninhabitedEnum);
27 pub struct IndirectUninhabitedStruct(UninhabitedStruct);
29 pub struct IndirectUninhabitedTupleStruct(UninhabitedTupleStruct);
31 pub struct IndirectUninhabitedVariants(UninhabitedVariants);
35 // This test checks that an empty match on a non-exhaustive uninhabited type from the defining crate
36 // will compile. In particular, this enables the `exhaustive_patterns` feature as this can
37 // change the branch used in the compiler to determine this.
38 // Codegen is skipped because tests with long names can cause issues on Windows CI, see #60648.
40 fn cannot_empty_match_on_empty_enum_to_anything(x: IndirectUninhabitedEnum) -> A {
44 fn cannot_empty_match_on_empty_struct_to_anything(x: IndirectUninhabitedStruct) -> A {
48 fn cannot_empty_match_on_empty_tuple_struct_to_anything(x: IndirectUninhabitedTupleStruct) -> A {
52 fn cannot_empty_match_on_enum_with_empty_variants_struct_to_anything(
53 x: IndirectUninhabitedVariants,