2019-11-30 15:51:26 +00:00
|
|
|
#![feature(never_type)]
|
|
|
|
#![feature(exhaustive_patterns)]
|
|
|
|
#![deny(unreachable_patterns)]
|
|
|
|
enum Foo {}
|
|
|
|
|
2019-12-03 14:08:14 +00:00
|
|
|
struct NonEmptyStruct(bool);
|
2019-12-03 14:07:14 +00:00
|
|
|
union NonEmptyUnion1 {
|
|
|
|
foo: (),
|
|
|
|
}
|
|
|
|
union NonEmptyUnion2 {
|
|
|
|
foo: (),
|
|
|
|
bar: (),
|
|
|
|
}
|
2019-12-02 17:10:20 +00:00
|
|
|
enum NonEmptyEnum1 { //~ `NonEmptyEnum1` defined here
|
|
|
|
Foo(bool), //~ variant not covered
|
2019-11-30 15:51:26 +00:00
|
|
|
}
|
2019-12-02 17:10:20 +00:00
|
|
|
enum NonEmptyEnum2 { //~ `NonEmptyEnum2` defined here
|
|
|
|
Foo(bool), //~ variant not covered
|
|
|
|
Bar, //~ variant not covered
|
2019-11-30 15:51:26 +00:00
|
|
|
}
|
2019-12-02 17:10:20 +00:00
|
|
|
enum NonEmptyEnum5 { //~ `NonEmptyEnum5` defined here
|
2019-11-30 15:51:26 +00:00
|
|
|
V1, V2, V3, V4, V5,
|
|
|
|
}
|
|
|
|
|
|
|
|
fn foo(x: Foo) {
|
|
|
|
match x {} // ok
|
|
|
|
match x {
|
|
|
|
_ => {}, //~ ERROR unreachable pattern
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
match None::<!> {
|
|
|
|
None => {}
|
|
|
|
Some(_) => {} //~ ERROR unreachable pattern
|
|
|
|
}
|
|
|
|
match None::<Foo> {
|
|
|
|
None => {}
|
|
|
|
Some(_) => {} //~ ERROR unreachable pattern
|
|
|
|
}
|
|
|
|
|
|
|
|
match 0u8 {}
|
|
|
|
//~^ ERROR type `u8` is non-empty
|
|
|
|
match NonEmptyStruct(true) {}
|
2019-12-03 14:08:14 +00:00
|
|
|
//~^ ERROR type `NonEmptyStruct` is non-empty
|
2019-12-03 14:07:14 +00:00
|
|
|
match (NonEmptyUnion1 { foo: () }) {}
|
2019-12-03 14:08:14 +00:00
|
|
|
//~^ ERROR type `NonEmptyUnion1` is non-empty
|
2019-12-03 14:07:14 +00:00
|
|
|
match (NonEmptyUnion2 { foo: () }) {}
|
2019-12-03 14:08:14 +00:00
|
|
|
//~^ ERROR type `NonEmptyUnion2` is non-empty
|
2019-11-30 15:51:26 +00:00
|
|
|
match NonEmptyEnum1::Foo(true) {}
|
2019-12-02 17:10:20 +00:00
|
|
|
//~^ ERROR pattern `Foo` of type `NonEmptyEnum1` is not handled
|
2019-11-30 15:51:26 +00:00
|
|
|
match NonEmptyEnum2::Foo(true) {}
|
2019-12-02 17:10:20 +00:00
|
|
|
//~^ ERROR multiple patterns of type `NonEmptyEnum2` are not handled
|
2019-11-30 15:51:26 +00:00
|
|
|
match NonEmptyEnum5::V1 {}
|
2019-12-02 17:10:20 +00:00
|
|
|
//~^ ERROR multiple patterns of type `NonEmptyEnum5` are not handled
|
2019-11-30 15:51:26 +00:00
|
|
|
}
|