summaryrefslogtreecommitdiffstats
path: root/tests/ui/pattern/usefulness/empty-match.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
commit9835e2ae736235810b4ea1c162ca5e65c547e770 (patch)
tree3fcebf40ed70e581d776a8a4c65923e8ec20e026 /tests/ui/pattern/usefulness/empty-match.rs
parentReleasing progress-linux version 1.70.0+dfsg2-1~progress7.99u1. (diff)
downloadrustc-9835e2ae736235810b4ea1c162ca5e65c547e770.tar.xz
rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.zip
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/pattern/usefulness/empty-match.rs')
-rw-r--r--tests/ui/pattern/usefulness/empty-match.rs66
1 files changed, 66 insertions, 0 deletions
diff --git a/tests/ui/pattern/usefulness/empty-match.rs b/tests/ui/pattern/usefulness/empty-match.rs
index 9cdc0413b..062241faa 100644
--- a/tests/ui/pattern/usefulness/empty-match.rs
+++ b/tests/ui/pattern/usefulness/empty-match.rs
@@ -6,28 +6,49 @@
#![feature(never_type_fallback)]
#![cfg_attr(exhaustive_patterns, feature(exhaustive_patterns))]
#![deny(unreachable_patterns)]
+//~^ NOTE the lint level is defined here
extern crate empty;
enum EmptyEnum {}
struct NonEmptyStruct1;
+//~^ NOTE `NonEmptyStruct1` defined here
+//~| NOTE `NonEmptyStruct1` defined here
struct NonEmptyStruct2(bool);
+//~^ NOTE `NonEmptyStruct2` defined here
+//~| NOTE `NonEmptyStruct2` defined here
union NonEmptyUnion1 {
+ //~^ NOTE `NonEmptyUnion1` defined here
+ //~| NOTE `NonEmptyUnion1` defined here
foo: (),
}
union NonEmptyUnion2 {
+ //~^ NOTE `NonEmptyUnion2` defined here
+ //~| NOTE `NonEmptyUnion2` defined here
foo: (),
bar: (),
}
enum NonEmptyEnum1 {
Foo(bool),
+ //~^ NOTE `NonEmptyEnum1` defined here
+ //~| NOTE `NonEmptyEnum1` defined here
+ //~| NOTE not covered
+ //~| NOTE not covered
}
enum NonEmptyEnum2 {
Foo(bool),
+ //~^ NOTE `NonEmptyEnum2` defined here
+ //~| NOTE `NonEmptyEnum2` defined here
+ //~| NOTE not covered
+ //~| NOTE not covered
Bar,
+ //~^ NOTE not covered
+ //~| NOTE not covered
}
enum NonEmptyEnum5 {
+ //~^ NOTE `NonEmptyEnum5` defined here
+ //~| NOTE `NonEmptyEnum5` defined here
V1, V2, V3, V4, V5,
}
@@ -51,6 +72,16 @@ fn empty_foreign_enum(x: empty::EmptyForeignEnum) {
}
}
+fn empty_foreign_enum_private(x: Option<empty::SecretlyUninhabitedForeignStruct>) {
+ let None = x;
+ //~^ ERROR refutable pattern in local binding
+ //~| NOTE `let` bindings require an "irrefutable pattern"
+ //~| NOTE for more information, visit
+ //~| NOTE the matched value is of type
+ //~| NOTE pattern `Some(_)` not covered
+ //[exhaustive_patterns]~| NOTE currently uninhabited, but this variant contains private fields
+}
+
fn never(x: !) {
match x {} // ok
match x {
@@ -76,20 +107,55 @@ macro_rules! match_guarded_arm {
fn main() {
match_no_arms!(0u8); //~ ERROR type `u8` is non-empty
+ //~| NOTE the matched value is of type
match_no_arms!(NonEmptyStruct1); //~ ERROR type `NonEmptyStruct1` is non-empty
+ //~| NOTE the matched value is of type
match_no_arms!(NonEmptyStruct2(true)); //~ ERROR type `NonEmptyStruct2` is non-empty
+ //~| NOTE the matched value is of type
match_no_arms!((NonEmptyUnion1 { foo: () })); //~ ERROR type `NonEmptyUnion1` is non-empty
+ //~| NOTE the matched value is of type
match_no_arms!((NonEmptyUnion2 { foo: () })); //~ ERROR type `NonEmptyUnion2` is non-empty
+ //~| NOTE the matched value is of type
match_no_arms!(NonEmptyEnum1::Foo(true)); //~ ERROR `NonEmptyEnum1::Foo(_)` not covered
+ //~| NOTE pattern `NonEmptyEnum1::Foo(_)` not covered
+ //~| NOTE the matched value is of type
match_no_arms!(NonEmptyEnum2::Foo(true)); //~ ERROR `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
+ //~| NOTE patterns `NonEmptyEnum2::Foo(_)` and
+ //~| NOTE the matched value is of type
match_no_arms!(NonEmptyEnum5::V1); //~ ERROR `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
+ //~| NOTE patterns `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`
+ //~| NOTE the matched value is of type
match_guarded_arm!(0u8); //~ ERROR `_` not covered
+ //~| NOTE the matched value is of type
+ //~| NOTE pattern `_` not covered
+ //~| NOTE in this expansion of match_guarded_arm!
match_guarded_arm!(NonEmptyStruct1); //~ ERROR `NonEmptyStruct1` not covered
+ //~| NOTE pattern `NonEmptyStruct1` not covered
+ //~| NOTE the matched value is of type
+ //~| NOTE in this expansion of match_guarded_arm!
match_guarded_arm!(NonEmptyStruct2(true)); //~ ERROR `NonEmptyStruct2(_)` not covered
+ //~| NOTE the matched value is of type
+ //~| NOTE pattern `NonEmptyStruct2(_)` not covered
+ //~| NOTE in this expansion of match_guarded_arm!
match_guarded_arm!((NonEmptyUnion1 { foo: () })); //~ ERROR `NonEmptyUnion1 { .. }` not covered
+ //~| NOTE the matched value is of type
+ //~| NOTE pattern `NonEmptyUnion1 { .. }` not covered
+ //~| NOTE in this expansion of match_guarded_arm!
match_guarded_arm!((NonEmptyUnion2 { foo: () })); //~ ERROR `NonEmptyUnion2 { .. }` not covered
+ //~| NOTE the matched value is of type
+ //~| NOTE pattern `NonEmptyUnion2 { .. }` not covered
+ //~| NOTE in this expansion of match_guarded_arm!
match_guarded_arm!(NonEmptyEnum1::Foo(true)); //~ ERROR `NonEmptyEnum1::Foo(_)` not covered
+ //~| NOTE the matched value is of type
+ //~| NOTE pattern `NonEmptyEnum1::Foo(_)` not covered
+ //~| NOTE in this expansion of match_guarded_arm!
match_guarded_arm!(NonEmptyEnum2::Foo(true)); //~ ERROR `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
+ //~| NOTE the matched value is of type
+ //~| NOTE patterns `NonEmptyEnum2::Foo(_)` and
+ //~| NOTE in this expansion of match_guarded_arm!
match_guarded_arm!(NonEmptyEnum5::V1); //~ ERROR `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
+ //~| NOTE the matched value is of type
+ //~| NOTE patterns `NonEmptyEnum5::V1`,
+ //~| NOTE in this expansion of match_guarded_arm!
}