summaryrefslogtreecommitdiffstats
path: root/tests/ui/rfcs/rfc-2008-non-exhaustive
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/rfcs/rfc-2008-non-exhaustive')
-rw-r--r--tests/ui/rfcs/rfc-2008-non-exhaustive/enum_same_crate_empty_match.stderr20
-rw-r--r--tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns-dont-lint-on-arm.lint.stderr75
-rw-r--r--tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns-dont-lint-on-arm.normal.stderr31
-rw-r--r--tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns-dont-lint-on-arm.rs53
-rw-r--r--tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns.rs85
-rw-r--r--tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns.stderr125
-rw-r--r--tests/ui/rfcs/rfc-2008-non-exhaustive/stable-omitted-patterns.rs8
-rw-r--r--tests/ui/rfcs/rfc-2008-non-exhaustive/stable-omitted-patterns.stderr12
-rw-r--r--tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match.stderr8
-rw-r--r--tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_same_crate.stderr8
-rw-r--r--tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.stderr8
11 files changed, 323 insertions, 110 deletions
diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/enum_same_crate_empty_match.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/enum_same_crate_empty_match.stderr
index de1bf8be8..7386f10a6 100644
--- a/tests/ui/rfcs/rfc-2008-non-exhaustive/enum_same_crate_empty_match.stderr
+++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/enum_same_crate_empty_match.stderr
@@ -17,18 +17,18 @@ LL | match NonExhaustiveEnum::Unit {}
| ^^^^^^^^^^^^^^^^^^^^^^^ patterns `NonExhaustiveEnum::Unit`, `NonExhaustiveEnum::Tuple(_)` and `NonExhaustiveEnum::Struct { .. }` not covered
|
note: `NonExhaustiveEnum` defined here
- --> $DIR/enum_same_crate_empty_match.rs:5:5
+ --> $DIR/enum_same_crate_empty_match.rs:4:10
|
LL | pub enum NonExhaustiveEnum {
- | -----------------
+ | ^^^^^^^^^^^^^^^^^
LL | Unit,
- | ^^^^ not covered
+ | ---- not covered
LL |
LL | Tuple(u32),
- | ^^^^^ not covered
+ | ----- not covered
LL |
LL | Struct { field: u32 }
- | ^^^^^^ not covered
+ | ------ not covered
= note: the matched value is of type `NonExhaustiveEnum`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
|
@@ -44,18 +44,18 @@ LL | match NormalEnum::Unit {}
| ^^^^^^^^^^^^^^^^ patterns `NormalEnum::Unit`, `NormalEnum::Tuple(_)` and `NormalEnum::Struct { .. }` not covered
|
note: `NormalEnum` defined here
- --> $DIR/enum_same_crate_empty_match.rs:14:5
+ --> $DIR/enum_same_crate_empty_match.rs:13:10
|
LL | pub enum NormalEnum {
- | ----------
+ | ^^^^^^^^^^
LL | Unit,
- | ^^^^ not covered
+ | ---- not covered
LL |
LL | Tuple(u32),
- | ^^^^^ not covered
+ | ----- not covered
LL |
LL | Struct { field: u32 }
- | ^^^^^^ not covered
+ | ------ not covered
= note: the matched value is of type `NormalEnum`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
|
diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns-dont-lint-on-arm.lint.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns-dont-lint-on-arm.lint.stderr
new file mode 100644
index 000000000..9192c6614
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns-dont-lint-on-arm.lint.stderr
@@ -0,0 +1,75 @@
+error: some variants are not matched explicitly
+ --> $DIR/omitted-patterns-dont-lint-on-arm.rs:15:11
+ |
+LL | match val {
+ | ^^^ pattern `NonExhaustiveEnum::Struct { .. }` not covered
+ |
+ = help: ensure that all variants are matched explicitly by adding the suggested match arms
+ = note: the matched value is of type `NonExhaustiveEnum` and the `non_exhaustive_omitted_patterns` attribute was found
+note: the lint level is defined here
+ --> $DIR/omitted-patterns-dont-lint-on-arm.rs:14:12
+ |
+LL | #[deny(non_exhaustive_omitted_patterns)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: some variants are not matched explicitly
+ --> $DIR/omitted-patterns-dont-lint-on-arm.rs:23:11
+ |
+LL | match val {
+ | ^^^ pattern `NonExhaustiveEnum::Struct { .. }` not covered
+ |
+ = help: ensure that all variants are matched explicitly by adding the suggested match arms
+ = note: the matched value is of type `NonExhaustiveEnum` and the `non_exhaustive_omitted_patterns` attribute was found
+note: the lint level is defined here
+ --> $DIR/omitted-patterns-dont-lint-on-arm.rs:22:27
+ |
+LL | #[cfg_attr(lint, deny(non_exhaustive_omitted_patterns))]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+warning: the lint level must be set on the whole match
+ --> $DIR/omitted-patterns-dont-lint-on-arm.rs:34:9
+ |
+LL | #[deny(non_exhaustive_omitted_patterns)]
+ | ------------------------------- remove this attribute
+LL | _ => {}
+ | ^
+ |
+ = help: it no longer has any effect to set the lint level on an individual match arm
+help: set the lint level on the whole match
+ |
+LL + #[deny(non_exhaustive_omitted_patterns)]
+LL | match val {
+ |
+
+warning: the lint level must be set on the whole match
+ --> $DIR/omitted-patterns-dont-lint-on-arm.rs:42:9
+ |
+LL | #[cfg_attr(lint, deny(non_exhaustive_omitted_patterns))]
+ | ------------------------------- remove this attribute
+LL | _ => {}
+ | ^
+ |
+ = help: it no longer has any effect to set the lint level on an individual match arm
+help: set the lint level on the whole match
+ |
+LL + #[deny(non_exhaustive_omitted_patterns)]
+LL | match val {
+ |
+
+warning: the lint level must be set on the whole match
+ --> $DIR/omitted-patterns-dont-lint-on-arm.rs:50:9
+ |
+LL | #[cfg_attr(lint, warn(non_exhaustive_omitted_patterns))]
+ | ------------------------------- remove this attribute
+LL | _ => {}
+ | ^
+ |
+ = help: it no longer has any effect to set the lint level on an individual match arm
+help: set the lint level on the whole match
+ |
+LL + #[warn(non_exhaustive_omitted_patterns)]
+LL | match val {
+ |
+
+error: aborting due to 2 previous errors; 3 warnings emitted
+
diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns-dont-lint-on-arm.normal.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns-dont-lint-on-arm.normal.stderr
new file mode 100644
index 000000000..46093eb9f
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns-dont-lint-on-arm.normal.stderr
@@ -0,0 +1,31 @@
+error: some variants are not matched explicitly
+ --> $DIR/omitted-patterns-dont-lint-on-arm.rs:15:11
+ |
+LL | match val {
+ | ^^^ pattern `NonExhaustiveEnum::Struct { .. }` not covered
+ |
+ = help: ensure that all variants are matched explicitly by adding the suggested match arms
+ = note: the matched value is of type `NonExhaustiveEnum` and the `non_exhaustive_omitted_patterns` attribute was found
+note: the lint level is defined here
+ --> $DIR/omitted-patterns-dont-lint-on-arm.rs:14:12
+ |
+LL | #[deny(non_exhaustive_omitted_patterns)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+warning: the lint level must be set on the whole match
+ --> $DIR/omitted-patterns-dont-lint-on-arm.rs:34:9
+ |
+LL | #[deny(non_exhaustive_omitted_patterns)]
+ | ------------------------------- remove this attribute
+LL | _ => {}
+ | ^
+ |
+ = help: it no longer has any effect to set the lint level on an individual match arm
+help: set the lint level on the whole match
+ |
+LL + #[deny(non_exhaustive_omitted_patterns)]
+LL | match val {
+ |
+
+error: aborting due to previous error; 1 warning emitted
+
diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns-dont-lint-on-arm.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns-dont-lint-on-arm.rs
new file mode 100644
index 000000000..33f9f56a5
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns-dont-lint-on-arm.rs
@@ -0,0 +1,53 @@
+// revisions: normal lint
+// Test that putting the lint level on a match arm emits a warning, as this was previously
+// meaningful and is no longer.
+#![feature(non_exhaustive_omitted_patterns_lint)]
+
+// aux-build:enums.rs
+extern crate enums;
+
+use enums::NonExhaustiveEnum;
+
+fn main() {
+ let val = NonExhaustiveEnum::Unit;
+
+ #[deny(non_exhaustive_omitted_patterns)]
+ match val {
+ //~^ ERROR some variants are not matched explicitly
+ NonExhaustiveEnum::Unit => {}
+ NonExhaustiveEnum::Tuple(_) => {}
+ _ => {}
+ }
+
+ #[cfg_attr(lint, deny(non_exhaustive_omitted_patterns))]
+ match val {
+ //[lint]~^ ERROR some variants are not matched explicitly
+ NonExhaustiveEnum::Unit => {}
+ NonExhaustiveEnum::Tuple(_) => {}
+ _ => {}
+ }
+
+ match val {
+ NonExhaustiveEnum::Unit => {}
+ NonExhaustiveEnum::Tuple(_) => {}
+ #[deny(non_exhaustive_omitted_patterns)]
+ _ => {}
+ }
+ //~^^ WARN lint level must be set on the whole match
+
+ match val {
+ NonExhaustiveEnum::Unit => {}
+ NonExhaustiveEnum::Tuple(_) => {}
+ #[cfg_attr(lint, deny(non_exhaustive_omitted_patterns))]
+ _ => {}
+ }
+ //[lint]~^^ WARN lint level must be set on the whole match
+
+ match val {
+ NonExhaustiveEnum::Unit => {}
+ NonExhaustiveEnum::Tuple(_) => {}
+ #[cfg_attr(lint, warn(non_exhaustive_omitted_patterns))]
+ _ => {}
+ }
+ //[lint]~^^ WARN lint level must be set on the whole match
+}
diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns.rs
index 3482af747..e0a6051a8 100644
--- a/tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns.rs
+++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns.rs
@@ -13,8 +13,8 @@ use enums::{
EmptyNonExhaustiveEnum, NestedNonExhaustive, NonExhaustiveEnum, NonExhaustiveSingleVariant,
VariantNonExhaustive,
};
-use unstable::{UnstableEnum, OnlyUnstableEnum, UnstableStruct, OnlyUnstableStruct};
use structs::{FunctionalRecord, MixedVisFields, NestedStruct, NormalStruct};
+use unstable::{OnlyUnstableEnum, OnlyUnstableStruct, UnstableEnum, UnstableStruct};
#[non_exhaustive]
#[derive(Default)]
@@ -35,10 +35,10 @@ fn main() {
let enumeration = Bar::A;
// Ok: this is a crate local non_exhaustive enum
+ #[deny(non_exhaustive_omitted_patterns)]
match enumeration {
Bar::A => {}
Bar::B => {}
- #[deny(non_exhaustive_omitted_patterns)]
_ => {}
}
@@ -51,50 +51,87 @@ fn main() {
_ => {}
}
+ #[deny(non_exhaustive_omitted_patterns)]
match non_enum {
+ //~^ some variants are not matched explicitly
NonExhaustiveEnum::Unit => {}
NonExhaustiveEnum::Tuple(_) => {}
- #[deny(non_exhaustive_omitted_patterns)]
_ => {}
}
- //~^^ some variants are not matched explicitly
+ #[deny(non_exhaustive_omitted_patterns)]
match non_enum {
+ //~^ some variants are not matched explicitly
NonExhaustiveEnum::Unit | NonExhaustiveEnum::Struct { .. } => {}
- #[deny(non_exhaustive_omitted_patterns)]
_ => {}
}
- //~^^ some variants are not matched explicitly
let x = 5;
+ // We ignore the guard.
+ #[deny(non_exhaustive_omitted_patterns)]
match non_enum {
NonExhaustiveEnum::Unit if x > 10 => {}
NonExhaustiveEnum::Tuple(_) => {}
NonExhaustiveEnum::Struct { .. } => {}
- #[deny(non_exhaustive_omitted_patterns)]
_ => {}
}
- //~^^ some variants are not matched explicitly
+
+ #[deny(non_exhaustive_omitted_patterns)]
+ match (non_enum, true) {
+ (NonExhaustiveEnum::Unit, true) => {}
+ (NonExhaustiveEnum::Tuple(_), false) => {}
+ (NonExhaustiveEnum::Struct { .. }, false) => {}
+ _ => {}
+ }
+ #[deny(non_exhaustive_omitted_patterns)]
+ match (non_enum, true) {
+ //~^ some variants are not matched explicitly
+ (NonExhaustiveEnum::Unit, true) => {}
+ (NonExhaustiveEnum::Tuple(_), false) => {}
+ _ => {}
+ }
+
+ #[deny(non_exhaustive_omitted_patterns)]
+ match (true, non_enum) {
+ (true, NonExhaustiveEnum::Unit) => {}
+ (false, NonExhaustiveEnum::Tuple(_)) => {}
+ (false, NonExhaustiveEnum::Struct { .. }) => {}
+ _ => {}
+ }
+ #[deny(non_exhaustive_omitted_patterns)]
+ match (true, non_enum) {
+ //~^ some variants are not matched explicitly
+ (true, NonExhaustiveEnum::Unit) => {}
+ (false, NonExhaustiveEnum::Tuple(_)) => {}
+ _ => {}
+ }
+
+ #[deny(non_exhaustive_omitted_patterns)]
+ match Some(non_enum) {
+ //~^ some variants are not matched explicitly
+ Some(NonExhaustiveEnum::Unit) => {}
+ Some(NonExhaustiveEnum::Tuple(_)) => {}
+ _ => {}
+ }
// Ok: all covered and not `unreachable-patterns`
#[deny(unreachable_patterns)]
+ #[deny(non_exhaustive_omitted_patterns)]
match non_enum {
NonExhaustiveEnum::Unit => {}
NonExhaustiveEnum::Tuple(_) => {}
NonExhaustiveEnum::Struct { .. } => {}
- #[deny(non_exhaustive_omitted_patterns)]
_ => {}
}
#[deny(non_exhaustive_omitted_patterns)]
match NestedNonExhaustive::B {
+ //~^ some variants are not matched explicitly
NestedNonExhaustive::A(NonExhaustiveEnum::Unit) => {}
NestedNonExhaustive::A(_) => {}
NestedNonExhaustive::B => {}
_ => {}
}
- //~^^ some variants are not matched explicitly
- //~^^^^^ some variants are not matched explicitly
#[warn(non_exhaustive_omitted_patterns)]
match VariantNonExhaustive::Baz(1, 2) {
@@ -120,30 +157,36 @@ fn main() {
#[warn(non_exhaustive_omitted_patterns)]
let MixedVisFields { a, b, .. } = MixedVisFields::default();
- // Ok: because this only has 1 variant
+ // Ok: this only has 1 variant
#[deny(non_exhaustive_omitted_patterns)]
match NonExhaustiveSingleVariant::A(true) {
NonExhaustiveSingleVariant::A(true) => {}
_ => {}
}
+ // We can't catch the case below, so for consistency we don't catch this one either.
#[deny(non_exhaustive_omitted_patterns)]
match NonExhaustiveSingleVariant::A(true) {
_ => {}
}
- //~^^ some variants are not matched explicitly
+ // We can't catch this case, because this would require digging fully through all the values of
+ // any type we encounter. We need to be able to only consider present constructors.
+ #[deny(non_exhaustive_omitted_patterns)]
+ match &NonExhaustiveSingleVariant::A(true) {
+ _ => {}
+ }
// Ok: we don't lint on `if let` expressions
#[deny(non_exhaustive_omitted_patterns)]
if let NonExhaustiveEnum::Tuple(_) = non_enum {}
+ #[deny(non_exhaustive_omitted_patterns)]
match UnstableEnum::Stable {
+ //~^ some variants are not matched explicitly
UnstableEnum::Stable => {}
UnstableEnum::Stable2 => {}
- #[deny(non_exhaustive_omitted_patterns)]
_ => {}
}
- //~^^ some variants are not matched explicitly
// Ok: the feature is on and all variants are matched
#[deny(non_exhaustive_omitted_patterns)]
@@ -164,10 +207,10 @@ fn main() {
#[deny(non_exhaustive_omitted_patterns)]
match OnlyUnstableEnum::Unstable {
+ //~^ some variants are not matched explicitly
OnlyUnstableEnum::Unstable => {}
_ => {}
}
- //~^^ some variants are not matched explicitly
#[warn(non_exhaustive_omitted_patterns)]
let OnlyUnstableStruct { unstable, .. } = OnlyUnstableStruct::new();
@@ -194,14 +237,13 @@ fn main() {
let local_refutable @ NonExhaustiveEnum::Unit = NonExhaustiveEnum::Unit;
//~^ refutable pattern in local binding
- // Check that matching on a reference results in a correctly spanned diagnostic
#[deny(non_exhaustive_omitted_patterns)]
match &non_enum {
+ //~^ some variants are not matched explicitly
NonExhaustiveEnum::Unit => {}
NonExhaustiveEnum::Tuple(_) => {}
_ => {}
}
- //~^^ some variants are not matched explicitly
}
#[deny(non_exhaustive_omitted_patterns)]
@@ -209,3 +251,10 @@ fn main() {
pub fn takes_non_exhaustive(_: NonExhaustiveEnum) {
let _closure = |_: NonExhaustiveEnum| {};
}
+
+// ICE #117033
+enum Void {}
+#[deny(non_exhaustive_omitted_patterns)]
+pub fn void(v: Void) -> ! {
+ match v {}
+}
diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns.stderr
index 923394474..7db61f124 100644
--- a/tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns.stderr
+++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns.stderr
@@ -1,5 +1,5 @@
warning: some fields are not explicitly listed
- --> $DIR/omitted-patterns.rs:102:9
+ --> $DIR/omitted-patterns.rs:139:9
|
LL | VariantNonExhaustive::Bar { x, .. } => {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ field `y` not listed
@@ -7,13 +7,13 @@ LL | VariantNonExhaustive::Bar { x, .. } => {}
= help: ensure that all fields are mentioned explicitly by adding the suggested fields
= note: the pattern is of type `VariantNonExhaustive` and the `non_exhaustive_omitted_patterns` attribute was found
note: the lint level is defined here
- --> $DIR/omitted-patterns.rs:99:12
+ --> $DIR/omitted-patterns.rs:136:12
|
LL | #[warn(non_exhaustive_omitted_patterns)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: some fields are not explicitly listed
- --> $DIR/omitted-patterns.rs:107:9
+ --> $DIR/omitted-patterns.rs:144:9
|
LL | let FunctionalRecord { first_field, second_field, .. } = FunctionalRecord::default();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ field `third_field` not listed
@@ -21,13 +21,13 @@ LL | let FunctionalRecord { first_field, second_field, .. } = FunctionalReco
= help: ensure that all fields are mentioned explicitly by adding the suggested fields
= note: the pattern is of type `FunctionalRecord` and the `non_exhaustive_omitted_patterns` attribute was found
note: the lint level is defined here
- --> $DIR/omitted-patterns.rs:106:12
+ --> $DIR/omitted-patterns.rs:143:12
|
LL | #[warn(non_exhaustive_omitted_patterns)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: some fields are not explicitly listed
- --> $DIR/omitted-patterns.rs:115:29
+ --> $DIR/omitted-patterns.rs:152:29
|
LL | let NestedStruct { bar: NormalStruct { first_field, .. }, .. } = NestedStruct::default();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ field `second_field` not listed
@@ -35,13 +35,13 @@ LL | let NestedStruct { bar: NormalStruct { first_field, .. }, .. } = Nested
= help: ensure that all fields are mentioned explicitly by adding the suggested fields
= note: the pattern is of type `NormalStruct` and the `non_exhaustive_omitted_patterns` attribute was found
note: the lint level is defined here
- --> $DIR/omitted-patterns.rs:114:12
+ --> $DIR/omitted-patterns.rs:151:12
|
LL | #[warn(non_exhaustive_omitted_patterns)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: some fields are not explicitly listed
- --> $DIR/omitted-patterns.rs:115:9
+ --> $DIR/omitted-patterns.rs:152:9
|
LL | let NestedStruct { bar: NormalStruct { first_field, .. }, .. } = NestedStruct::default();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ field `foo` not listed
@@ -50,7 +50,7 @@ LL | let NestedStruct { bar: NormalStruct { first_field, .. }, .. } = Nested
= note: the pattern is of type `NestedStruct` and the `non_exhaustive_omitted_patterns` attribute was found
warning: some fields are not explicitly listed
- --> $DIR/omitted-patterns.rs:173:9
+ --> $DIR/omitted-patterns.rs:216:9
|
LL | let OnlyUnstableStruct { unstable, .. } = OnlyUnstableStruct::new();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ field `unstable2` not listed
@@ -58,13 +58,13 @@ LL | let OnlyUnstableStruct { unstable, .. } = OnlyUnstableStruct::new();
= help: ensure that all fields are mentioned explicitly by adding the suggested fields
= note: the pattern is of type `OnlyUnstableStruct` and the `non_exhaustive_omitted_patterns` attribute was found
note: the lint level is defined here
- --> $DIR/omitted-patterns.rs:172:12
+ --> $DIR/omitted-patterns.rs:215:12
|
LL | #[warn(non_exhaustive_omitted_patterns)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: some fields are not explicitly listed
- --> $DIR/omitted-patterns.rs:181:9
+ --> $DIR/omitted-patterns.rs:224:9
|
LL | let UnstableStruct { stable, stable2, .. } = UnstableStruct::default();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ field `unstable` not listed
@@ -72,120 +72,125 @@ LL | let UnstableStruct { stable, stable2, .. } = UnstableStruct::default();
= help: ensure that all fields are mentioned explicitly by adding the suggested fields
= note: the pattern is of type `UnstableStruct` and the `non_exhaustive_omitted_patterns` attribute was found
note: the lint level is defined here
- --> $DIR/omitted-patterns.rs:180:12
+ --> $DIR/omitted-patterns.rs:223:12
|
LL | #[warn(non_exhaustive_omitted_patterns)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: some variants are not matched explicitly
- --> $DIR/omitted-patterns.rs:58:9
+ --> $DIR/omitted-patterns.rs:55:11
|
-LL | _ => {}
- | ^ pattern `NonExhaustiveEnum::Struct { .. }` not covered
+LL | match non_enum {
+ | ^^^^^^^^ pattern `NonExhaustiveEnum::Struct { .. }` not covered
|
= help: ensure that all variants are matched explicitly by adding the suggested match arms
= note: the matched value is of type `NonExhaustiveEnum` and the `non_exhaustive_omitted_patterns` attribute was found
note: the lint level is defined here
- --> $DIR/omitted-patterns.rs:57:16
+ --> $DIR/omitted-patterns.rs:54:12
|
-LL | #[deny(non_exhaustive_omitted_patterns)]
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | #[deny(non_exhaustive_omitted_patterns)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: some variants are not matched explicitly
- --> $DIR/omitted-patterns.rs:65:9
+ --> $DIR/omitted-patterns.rs:63:11
|
-LL | _ => {}
- | ^ pattern `NonExhaustiveEnum::Tuple(_)` not covered
+LL | match non_enum {
+ | ^^^^^^^^ pattern `NonExhaustiveEnum::Tuple(_)` not covered
|
= help: ensure that all variants are matched explicitly by adding the suggested match arms
= note: the matched value is of type `NonExhaustiveEnum` and the `non_exhaustive_omitted_patterns` attribute was found
note: the lint level is defined here
- --> $DIR/omitted-patterns.rs:64:16
+ --> $DIR/omitted-patterns.rs:62:12
|
-LL | #[deny(non_exhaustive_omitted_patterns)]
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | #[deny(non_exhaustive_omitted_patterns)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: some variants are not matched explicitly
- --> $DIR/omitted-patterns.rs:75:9
+ --> $DIR/omitted-patterns.rs:87:11
|
-LL | _ => {}
- | ^ pattern `NonExhaustiveEnum::Unit` not covered
+LL | match (non_enum, true) {
+ | ^^^^^^^^^^^^^^^^ pattern `(NonExhaustiveEnum::Struct { .. }, _)` not covered
|
= help: ensure that all variants are matched explicitly by adding the suggested match arms
- = note: the matched value is of type `NonExhaustiveEnum` and the `non_exhaustive_omitted_patterns` attribute was found
+ = note: the matched value is of type `(NonExhaustiveEnum, bool)` and the `non_exhaustive_omitted_patterns` attribute was found
note: the lint level is defined here
- --> $DIR/omitted-patterns.rs:74:16
+ --> $DIR/omitted-patterns.rs:86:12
|
-LL | #[deny(non_exhaustive_omitted_patterns)]
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | #[deny(non_exhaustive_omitted_patterns)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: some variants are not matched explicitly
- --> $DIR/omitted-patterns.rs:92:32
+ --> $DIR/omitted-patterns.rs:102:11
|
-LL | NestedNonExhaustive::A(_) => {}
- | ^ patterns `NonExhaustiveEnum::Tuple(_)` and `NonExhaustiveEnum::Struct { .. }` not covered
+LL | match (true, non_enum) {
+ | ^^^^^^^^^^^^^^^^ pattern `(_, NonExhaustiveEnum::Struct { .. })` not covered
|
= help: ensure that all variants are matched explicitly by adding the suggested match arms
- = note: the matched value is of type `NonExhaustiveEnum` and the `non_exhaustive_omitted_patterns` attribute was found
+ = note: the matched value is of type `(bool, NonExhaustiveEnum)` and the `non_exhaustive_omitted_patterns` attribute was found
note: the lint level is defined here
- --> $DIR/omitted-patterns.rs:89:12
+ --> $DIR/omitted-patterns.rs:101:12
|
LL | #[deny(non_exhaustive_omitted_patterns)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: some variants are not matched explicitly
- --> $DIR/omitted-patterns.rs:94:9
+ --> $DIR/omitted-patterns.rs:110:11
|
-LL | _ => {}
- | ^ pattern `NestedNonExhaustive::C` not covered
+LL | match Some(non_enum) {
+ | ^^^^^^^^^^^^^^ pattern `Some(NonExhaustiveEnum::Struct { .. })` not covered
|
= help: ensure that all variants are matched explicitly by adding the suggested match arms
- = note: the matched value is of type `NestedNonExhaustive` and the `non_exhaustive_omitted_patterns` attribute was found
+ = note: the matched value is of type `Option<NonExhaustiveEnum>` and the `non_exhaustive_omitted_patterns` attribute was found
+note: the lint level is defined here
+ --> $DIR/omitted-patterns.rs:109:12
+ |
+LL | #[deny(non_exhaustive_omitted_patterns)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: some variants are not matched explicitly
- --> $DIR/omitted-patterns.rs:132:9
+ --> $DIR/omitted-patterns.rs:128:11
|
-LL | _ => {}
- | ^ pattern `NonExhaustiveSingleVariant::A(_)` not covered
+LL | match NestedNonExhaustive::B {
+ | ^^^^^^^^^^^^^^^^^^^^^^ patterns `NestedNonExhaustive::C`, `NestedNonExhaustive::A(NonExhaustiveEnum::Tuple(_))` and `NestedNonExhaustive::A(NonExhaustiveEnum::Struct { .. })` not covered
|
= help: ensure that all variants are matched explicitly by adding the suggested match arms
- = note: the matched value is of type `NonExhaustiveSingleVariant` and the `non_exhaustive_omitted_patterns` attribute was found
+ = note: the matched value is of type `NestedNonExhaustive` and the `non_exhaustive_omitted_patterns` attribute was found
note: the lint level is defined here
- --> $DIR/omitted-patterns.rs:130:12
+ --> $DIR/omitted-patterns.rs:127:12
|
LL | #[deny(non_exhaustive_omitted_patterns)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: some variants are not matched explicitly
- --> $DIR/omitted-patterns.rs:144:9
+ --> $DIR/omitted-patterns.rs:184:11
|
-LL | _ => {}
- | ^ pattern `UnstableEnum::Unstable` not covered
+LL | match UnstableEnum::Stable {
+ | ^^^^^^^^^^^^^^^^^^^^ pattern `UnstableEnum::Unstable` not covered
|
= help: ensure that all variants are matched explicitly by adding the suggested match arms
= note: the matched value is of type `UnstableEnum` and the `non_exhaustive_omitted_patterns` attribute was found
note: the lint level is defined here
- --> $DIR/omitted-patterns.rs:143:16
+ --> $DIR/omitted-patterns.rs:183:12
|
-LL | #[deny(non_exhaustive_omitted_patterns)]
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | #[deny(non_exhaustive_omitted_patterns)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: some variants are not matched explicitly
- --> $DIR/omitted-patterns.rs:168:9
+ --> $DIR/omitted-patterns.rs:209:11
|
-LL | _ => {}
- | ^ pattern `OnlyUnstableEnum::Unstable2` not covered
+LL | match OnlyUnstableEnum::Unstable {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `OnlyUnstableEnum::Unstable2` not covered
|
= help: ensure that all variants are matched explicitly by adding the suggested match arms
= note: the matched value is of type `OnlyUnstableEnum` and the `non_exhaustive_omitted_patterns` attribute was found
note: the lint level is defined here
- --> $DIR/omitted-patterns.rs:165:12
+ --> $DIR/omitted-patterns.rs:208:12
|
LL | #[deny(non_exhaustive_omitted_patterns)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0005]: refutable pattern in local binding
- --> $DIR/omitted-patterns.rs:194:9
+ --> $DIR/omitted-patterns.rs:237:9
|
LL | let local_refutable @ NonExhaustiveEnum::Unit = NonExhaustiveEnum::Unit;
| ^^^^^^^^^^^^^^^ pattern `_` not covered
@@ -199,15 +204,15 @@ LL | let local_refutable @ NonExhaustiveEnum::Unit = NonExhaustiveEnum::Unit
| ++++++++++++++++
error: some variants are not matched explicitly
- --> $DIR/omitted-patterns.rs:202:9
+ --> $DIR/omitted-patterns.rs:241:11
|
-LL | _ => {}
- | ^ pattern `NonExhaustiveEnum::Struct { .. }` not covered
+LL | match &non_enum {
+ | ^^^^^^^^^ pattern `&NonExhaustiveEnum::Struct { .. }` not covered
|
= help: ensure that all variants are matched explicitly by adding the suggested match arms
- = note: the matched value is of type `NonExhaustiveEnum` and the `non_exhaustive_omitted_patterns` attribute was found
+ = note: the matched value is of type `&NonExhaustiveEnum` and the `non_exhaustive_omitted_patterns` attribute was found
note: the lint level is defined here
- --> $DIR/omitted-patterns.rs:198:12
+ --> $DIR/omitted-patterns.rs:240:12
|
LL | #[deny(non_exhaustive_omitted_patterns)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/stable-omitted-patterns.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/stable-omitted-patterns.rs
index 82ee68687..1828fdef9 100644
--- a/tests/ui/rfcs/rfc-2008-non-exhaustive/stable-omitted-patterns.rs
+++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/stable-omitted-patterns.rs
@@ -6,23 +6,23 @@
// aux-build:unstable.rs
extern crate unstable;
-use unstable::{UnstableEnum, OnlyUnstableEnum, UnstableStruct, OnlyUnstableStruct};
+use unstable::{OnlyUnstableEnum, OnlyUnstableStruct, UnstableEnum, UnstableStruct};
fn main() {
// OK: this matches all the stable variants
+ #[deny(non_exhaustive_omitted_patterns)]
match UnstableEnum::Stable {
UnstableEnum::Stable => {}
UnstableEnum::Stable2 => {}
- #[deny(non_exhaustive_omitted_patterns)]
_ => {}
}
+ #[deny(non_exhaustive_omitted_patterns)]
match UnstableEnum::Stable {
+ //~^ some variants are not matched explicitly
UnstableEnum::Stable => {}
- #[deny(non_exhaustive_omitted_patterns)]
_ => {}
}
- //~^^ some variants are not matched explicitly
// Ok: although this is a bit odd, we don't have anything to report
// since there is no stable variants and the feature is off
diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/stable-omitted-patterns.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/stable-omitted-patterns.stderr
index f38368590..27939176f 100644
--- a/tests/ui/rfcs/rfc-2008-non-exhaustive/stable-omitted-patterns.stderr
+++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/stable-omitted-patterns.stderr
@@ -13,18 +13,18 @@ LL | #[warn(non_exhaustive_omitted_patterns)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: some variants are not matched explicitly
- --> $DIR/stable-omitted-patterns.rs:23:9
+ --> $DIR/stable-omitted-patterns.rs:21:11
|
-LL | _ => {}
- | ^ pattern `UnstableEnum::Stable2` not covered
+LL | match UnstableEnum::Stable {
+ | ^^^^^^^^^^^^^^^^^^^^ pattern `UnstableEnum::Stable2` not covered
|
= help: ensure that all variants are matched explicitly by adding the suggested match arms
= note: the matched value is of type `UnstableEnum` and the `non_exhaustive_omitted_patterns` attribute was found
note: the lint level is defined here
- --> $DIR/stable-omitted-patterns.rs:22:16
+ --> $DIR/stable-omitted-patterns.rs:20:12
|
-LL | #[deny(non_exhaustive_omitted_patterns)]
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | #[deny(non_exhaustive_omitted_patterns)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error; 1 warning emitted
diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match.stderr
index a9c54af04..c125756a6 100644
--- a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match.stderr
+++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match.stderr
@@ -62,14 +62,14 @@ LL | match x {}
| ^ patterns `UninhabitedVariants::Tuple(_)` and `UninhabitedVariants::Struct { .. }` not covered
|
note: `UninhabitedVariants` defined here
- --> $DIR/auxiliary/uninhabited.rs:17:23
+ --> $DIR/auxiliary/uninhabited.rs:16:1
|
LL | pub enum UninhabitedVariants {
- | ----------------------------
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | #[non_exhaustive] Tuple(!),
- | ^^^^^ not covered
+ | ----- not covered
LL | #[non_exhaustive] Struct { x: ! }
- | ^^^^^^ not covered
+ | ------ not covered
= note: the matched value is of type `UninhabitedVariants`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
|
diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_same_crate.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_same_crate.stderr
index ec2a2f6f0..7a12aca85 100644
--- a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_same_crate.stderr
+++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_same_crate.stderr
@@ -43,14 +43,14 @@ LL | match x {}
| ^ patterns `UninhabitedVariants::Tuple(_)` and `UninhabitedVariants::Struct { .. }` not covered
|
note: `UninhabitedVariants` defined here
- --> $DIR/match_same_crate.rs:16:23
+ --> $DIR/match_same_crate.rs:15:10
|
LL | pub enum UninhabitedVariants {
- | -------------------
+ | ^^^^^^^^^^^^^^^^^^^
LL | #[non_exhaustive] Tuple(!),
- | ^^^^^ not covered
+ | ----- not covered
LL | #[non_exhaustive] Struct { x: ! }
- | ^^^^^^ not covered
+ | ------ not covered
= note: the matched value is of type `UninhabitedVariants`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
|
diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.stderr
index b6b777ec5..19e2546b0 100644
--- a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.stderr
+++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.stderr
@@ -62,14 +62,14 @@ LL | match x {}
| ^ patterns `UninhabitedVariants::Tuple(_)` and `UninhabitedVariants::Struct { .. }` not covered
|
note: `UninhabitedVariants` defined here
- --> $DIR/auxiliary/uninhabited.rs:17:23
+ --> $DIR/auxiliary/uninhabited.rs:16:1
|
LL | pub enum UninhabitedVariants {
- | ----------------------------
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | #[non_exhaustive] Tuple(!),
- | ^^^^^ not covered
+ | ----- not covered
LL | #[non_exhaustive] Struct { x: ! }
- | ^^^^^^ not covered
+ | ------ not covered
= note: the matched value is of type `UninhabitedVariants`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
|