summaryrefslogtreecommitdiffstats
path: root/tests/ui/pattern/usefulness
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/pattern/usefulness')
-rw-r--r--tests/ui/pattern/usefulness/const-partial_eq-fallback-ice.stderr2
-rw-r--r--tests/ui/pattern/usefulness/empty-match-check-notes.exhaustive_patterns.stderr63
-rw-r--r--tests/ui/pattern/usefulness/empty-match-check-notes.normal.stderr62
-rw-r--r--tests/ui/pattern/usefulness/empty-match-check-notes.rs52
-rw-r--r--tests/ui/pattern/usefulness/empty-match.exhaustive_patterns.stderr284
-rw-r--r--tests/ui/pattern/usefulness/empty-match.normal.stderr283
-rw-r--r--tests/ui/pattern/usefulness/empty-match.rs178
-rw-r--r--tests/ui/pattern/usefulness/empty-types.exhaustive_patterns.stderr393
-rw-r--r--tests/ui/pattern/usefulness/empty-types.normal.stderr617
-rw-r--r--tests/ui/pattern/usefulness/empty-types.rs665
-rw-r--r--tests/ui/pattern/usefulness/guards.stderr2
-rw-r--r--tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.allow.stderr17
-rw-r--r--tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.deny.stderr66
-rw-r--r--tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.rs54
-rw-r--r--tests/ui/pattern/usefulness/integer-ranges/precise_pointer_matching-message.stderr2
-rw-r--r--tests/ui/pattern/usefulness/integer-ranges/reachability.rs5
-rw-r--r--tests/ui/pattern/usefulness/integer-ranges/reachability.stderr56
-rw-r--r--tests/ui/pattern/usefulness/issue-105479-str-non-exhaustiveness.stderr2
-rw-r--r--tests/ui/pattern/usefulness/issue-118437-exponential-time-on-diagonal-match.rs72
-rw-r--r--tests/ui/pattern/usefulness/issue-12116.stderr2
-rw-r--r--tests/ui/pattern/usefulness/issue-12369.stderr2
-rw-r--r--tests/ui/pattern/usefulness/issue-13727.stderr2
-rw-r--r--tests/ui/pattern/usefulness/issue-15129.stderr2
-rw-r--r--tests/ui/pattern/usefulness/issue-2111.stderr2
-rw-r--r--tests/ui/pattern/usefulness/issue-30240-b.stderr2
-rw-r--r--tests/ui/pattern/usefulness/issue-3096-1.stderr2
-rw-r--r--tests/ui/pattern/usefulness/issue-3096-2.stderr2
-rw-r--r--tests/ui/pattern/usefulness/issue-31561.stderr2
-rw-r--r--tests/ui/pattern/usefulness/issue-3601.rs2
-rw-r--r--tests/ui/pattern/usefulness/issue-3601.stderr8
-rw-r--r--tests/ui/pattern/usefulness/issue-39362.stderr2
-rw-r--r--tests/ui/pattern/usefulness/issue-40221.stderr2
-rw-r--r--tests/ui/pattern/usefulness/issue-4321.stderr2
-rw-r--r--tests/ui/pattern/usefulness/issue-50900.stderr2
-rw-r--r--tests/ui/pattern/usefulness/issue-56379.stderr2
-rw-r--r--tests/ui/pattern/usefulness/issue-72377.stderr2
-rw-r--r--tests/ui/pattern/usefulness/issue-78123-non-exhaustive-reference.stderr2
-rw-r--r--tests/ui/pattern/usefulness/issue-82772-match-box-as-struct.stderr2
-rw-r--r--tests/ui/pattern/usefulness/issue-85222-types-containing-non-exhaustive-types.stderr8
-rw-r--r--tests/ui/pattern/usefulness/match-non-exhaustive.stderr10
-rw-r--r--tests/ui/pattern/usefulness/match-privately-empty.stderr2
-rw-r--r--tests/ui/pattern/usefulness/match-ref-ice.stderr2
-rw-r--r--tests/ui/pattern/usefulness/match-slice-patterns.stderr2
-rw-r--r--tests/ui/pattern/usefulness/nested-non-exhaustive-enums.stderr2
-rw-r--r--tests/ui/pattern/usefulness/refutable-pattern-in-fn-arg.stderr2
-rw-r--r--tests/ui/pattern/usefulness/slice-patterns-exhaustiveness.rs4
-rw-r--r--tests/ui/pattern/usefulness/slice-patterns-exhaustiveness.stderr42
-rw-r--r--tests/ui/pattern/usefulness/slice_of_empty.rs6
-rw-r--r--tests/ui/pattern/usefulness/slice_of_empty.stderr31
-rw-r--r--tests/ui/pattern/usefulness/struct-like-enum-nonexhaustive.stderr2
-rw-r--r--tests/ui/pattern/usefulness/struct-pattern-match-useless.stderr2
-rw-r--r--tests/ui/pattern/usefulness/tuple-struct-nonexhaustive.stderr2
-rw-r--r--tests/ui/pattern/usefulness/unstable-gated-patterns.stderr2
53 files changed, 2348 insertions, 690 deletions
diff --git a/tests/ui/pattern/usefulness/const-partial_eq-fallback-ice.stderr b/tests/ui/pattern/usefulness/const-partial_eq-fallback-ice.stderr
index dbd46da44..2352ecd0a 100644
--- a/tests/ui/pattern/usefulness/const-partial_eq-fallback-ice.stderr
+++ b/tests/ui/pattern/usefulness/const-partial_eq-fallback-ice.stderr
@@ -7,5 +7,5 @@ LL | if let CONSTANT = &&MyType {
= note: the traits must be derived, manual `impl`s are not sufficient
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/pattern/usefulness/empty-match-check-notes.exhaustive_patterns.stderr b/tests/ui/pattern/usefulness/empty-match-check-notes.exhaustive_patterns.stderr
new file mode 100644
index 000000000..304435cb2
--- /dev/null
+++ b/tests/ui/pattern/usefulness/empty-match-check-notes.exhaustive_patterns.stderr
@@ -0,0 +1,63 @@
+error: unreachable pattern
+ --> $DIR/empty-match-check-notes.rs:17:9
+ |
+LL | _ => {}
+ | ^
+ |
+note: the lint level is defined here
+ --> $DIR/empty-match-check-notes.rs:7:9
+ |
+LL | #![deny(unreachable_patterns)]
+ | ^^^^^^^^^^^^^^^^^^^^
+
+error: unreachable pattern
+ --> $DIR/empty-match-check-notes.rs:20:9
+ |
+LL | _ if false => {}
+ | ^
+
+error: unreachable pattern
+ --> $DIR/empty-match-check-notes.rs:27:9
+ |
+LL | _ => {}
+ | ^
+
+error: unreachable pattern
+ --> $DIR/empty-match-check-notes.rs:30:9
+ |
+LL | _ if false => {}
+ | ^
+
+error[E0005]: refutable pattern in local binding
+ --> $DIR/empty-match-check-notes.rs:35:9
+ |
+LL | let None = x;
+ | ^^^^ pattern `Some(_)` not covered
+ |
+ = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
+ = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
+ = note: pattern `Some(_)` is currently uninhabited, but this variant contains private fields which may become inhabited in the future
+ = note: the matched value is of type `Option<SecretlyUninhabitedForeignStruct>`
+help: you might want to use `if let` to ignore the variant that isn't matched
+ |
+LL | if let None = x { todo!() };
+ | ++ +++++++++++
+
+error[E0004]: non-exhaustive patterns: `_` not covered
+ --> $DIR/empty-match-check-notes.rs:45:11
+ |
+LL | match 0u8 {
+ | ^^^ pattern `_` not covered
+ |
+ = note: the matched value is of type `u8`
+ = note: match arms with guards don't count towards exhaustivity
+help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
+ |
+LL ~ _ if false => {},
+LL + _ => todo!()
+ |
+
+error: aborting due to 6 previous errors
+
+Some errors have detailed explanations: E0004, E0005.
+For more information about an error, try `rustc --explain E0004`.
diff --git a/tests/ui/pattern/usefulness/empty-match-check-notes.normal.stderr b/tests/ui/pattern/usefulness/empty-match-check-notes.normal.stderr
new file mode 100644
index 000000000..40494b726
--- /dev/null
+++ b/tests/ui/pattern/usefulness/empty-match-check-notes.normal.stderr
@@ -0,0 +1,62 @@
+error: unreachable pattern
+ --> $DIR/empty-match-check-notes.rs:17:9
+ |
+LL | _ => {}
+ | ^
+ |
+note: the lint level is defined here
+ --> $DIR/empty-match-check-notes.rs:7:9
+ |
+LL | #![deny(unreachable_patterns)]
+ | ^^^^^^^^^^^^^^^^^^^^
+
+error: unreachable pattern
+ --> $DIR/empty-match-check-notes.rs:20:9
+ |
+LL | _ if false => {}
+ | ^
+
+error: unreachable pattern
+ --> $DIR/empty-match-check-notes.rs:27:9
+ |
+LL | _ => {}
+ | ^
+
+error: unreachable pattern
+ --> $DIR/empty-match-check-notes.rs:30:9
+ |
+LL | _ if false => {}
+ | ^
+
+error[E0005]: refutable pattern in local binding
+ --> $DIR/empty-match-check-notes.rs:35:9
+ |
+LL | let None = x;
+ | ^^^^ pattern `Some(_)` not covered
+ |
+ = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
+ = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
+ = note: the matched value is of type `Option<SecretlyUninhabitedForeignStruct>`
+help: you might want to use `if let` to ignore the variant that isn't matched
+ |
+LL | if let None = x { todo!() };
+ | ++ +++++++++++
+
+error[E0004]: non-exhaustive patterns: `_` not covered
+ --> $DIR/empty-match-check-notes.rs:45:11
+ |
+LL | match 0u8 {
+ | ^^^ pattern `_` not covered
+ |
+ = note: the matched value is of type `u8`
+ = note: match arms with guards don't count towards exhaustivity
+help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
+ |
+LL ~ _ if false => {},
+LL + _ => todo!()
+ |
+
+error: aborting due to 6 previous errors
+
+Some errors have detailed explanations: E0004, E0005.
+For more information about an error, try `rustc --explain E0004`.
diff --git a/tests/ui/pattern/usefulness/empty-match-check-notes.rs b/tests/ui/pattern/usefulness/empty-match-check-notes.rs
new file mode 100644
index 000000000..ee9ff3dcf
--- /dev/null
+++ b/tests/ui/pattern/usefulness/empty-match-check-notes.rs
@@ -0,0 +1,52 @@
+// aux-build:empty.rs
+// revisions: normal exhaustive_patterns
+//
+// This tests a match with no arms on various types, and checks NOTEs.
+#![feature(never_type)]
+#![cfg_attr(exhaustive_patterns, feature(exhaustive_patterns))]
+#![deny(unreachable_patterns)]
+//~^ NOTE the lint level is defined here
+
+extern crate empty;
+
+enum EmptyEnum {}
+
+fn empty_enum(x: EmptyEnum) {
+ match x {} // ok
+ match x {
+ _ => {} //~ ERROR unreachable pattern
+ }
+ match x {
+ _ if false => {} //~ ERROR unreachable pattern
+ }
+}
+
+fn empty_foreign_enum(x: empty::EmptyForeignEnum) {
+ match x {} // ok
+ match x {
+ _ => {} //~ ERROR unreachable pattern
+ }
+ match x {
+ _ if false => {} //~ ERROR unreachable pattern
+ }
+}
+
+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 main() {
+ match 0u8 {
+ //~^ ERROR `_` not covered
+ //~| NOTE the matched value is of type
+ //~| NOTE match arms with guards don't count towards exhaustivity
+ //~| NOTE pattern `_` not covered
+ _ if false => {}
+ }
+}
diff --git a/tests/ui/pattern/usefulness/empty-match.exhaustive_patterns.stderr b/tests/ui/pattern/usefulness/empty-match.exhaustive_patterns.stderr
index 8f9bd5bde..9c3bebd77 100644
--- a/tests/ui/pattern/usefulness/empty-match.exhaustive_patterns.stderr
+++ b/tests/ui/pattern/usefulness/empty-match.exhaustive_patterns.stderr
@@ -1,62 +1,5 @@
-error: unreachable pattern
- --> $DIR/empty-match.rs:68:9
- |
-LL | _ => {},
- | ^
- |
-note: the lint level is defined here
- --> $DIR/empty-match.rs:8:9
- |
-LL | #![deny(unreachable_patterns)]
- | ^^^^^^^^^^^^^^^^^^^^
-
-error: unreachable pattern
- --> $DIR/empty-match.rs:71:9
- |
-LL | _ if false => {},
- | ^
-
-error: unreachable pattern
- --> $DIR/empty-match.rs:78:9
- |
-LL | _ => {},
- | ^
-
-error: unreachable pattern
- --> $DIR/empty-match.rs:81:9
- |
-LL | _ if false => {},
- | ^
-
-error[E0005]: refutable pattern in local binding
- --> $DIR/empty-match.rs:86:9
- |
-LL | let None = x;
- | ^^^^ pattern `Some(_)` not covered
- |
- = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
- = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
- = note: pattern `Some(_)` is currently uninhabited, but this variant contains private fields which may become inhabited in the future
- = note: the matched value is of type `Option<SecretlyUninhabitedForeignStruct>`
-help: you might want to use `if let` to ignore the variant that isn't matched
- |
-LL | if let None = x { todo!() };
- | ++ +++++++++++
-
-error: unreachable pattern
- --> $DIR/empty-match.rs:98:9
- |
-LL | _ => {},
- | ^
-
-error: unreachable pattern
- --> $DIR/empty-match.rs:101:9
- |
-LL | _ if false => {},
- | ^
-
error[E0004]: non-exhaustive patterns: type `u8` is non-empty
- --> $DIR/empty-match.rs:119:20
+ --> $DIR/empty-match.rs:46:20
|
LL | match_no_arms!(0u8);
| ^^^
@@ -65,122 +8,121 @@ LL | match_no_arms!(0u8);
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
error[E0004]: non-exhaustive patterns: type `NonEmptyStruct1` is non-empty
- --> $DIR/empty-match.rs:121:20
+ --> $DIR/empty-match.rs:47:20
|
LL | match_no_arms!(NonEmptyStruct1);
| ^^^^^^^^^^^^^^^
|
note: `NonEmptyStruct1` defined here
- --> $DIR/empty-match.rs:15:8
+ --> $DIR/empty-match.rs:22:12
|
-LL | struct NonEmptyStruct1;
- | ^^^^^^^^^^^^^^^
+LL | struct NonEmptyStruct1;
+ | ^^^^^^^^^^^^^^^
= note: the matched value is of type `NonEmptyStruct1`
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
error[E0004]: non-exhaustive patterns: type `NonEmptyStruct2` is non-empty
- --> $DIR/empty-match.rs:123:20
+ --> $DIR/empty-match.rs:48:20
|
LL | match_no_arms!(NonEmptyStruct2(true));
| ^^^^^^^^^^^^^^^^^^^^^
|
note: `NonEmptyStruct2` defined here
- --> $DIR/empty-match.rs:18:8
+ --> $DIR/empty-match.rs:23:12
|
-LL | struct NonEmptyStruct2(bool);
- | ^^^^^^^^^^^^^^^
+LL | struct NonEmptyStruct2(bool);
+ | ^^^^^^^^^^^^^^^
= note: the matched value is of type `NonEmptyStruct2`
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
error[E0004]: non-exhaustive patterns: type `NonEmptyUnion1` is non-empty
- --> $DIR/empty-match.rs:125:20
+ --> $DIR/empty-match.rs:49:20
|
LL | match_no_arms!((NonEmptyUnion1 { foo: () }));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: `NonEmptyUnion1` defined here
- --> $DIR/empty-match.rs:21:7
+ --> $DIR/empty-match.rs:24:11
|
-LL | union NonEmptyUnion1 {
- | ^^^^^^^^^^^^^^
+LL | union NonEmptyUnion1 {
+ | ^^^^^^^^^^^^^^
= note: the matched value is of type `NonEmptyUnion1`
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
error[E0004]: non-exhaustive patterns: type `NonEmptyUnion2` is non-empty
- --> $DIR/empty-match.rs:127:20
+ --> $DIR/empty-match.rs:50:20
|
LL | match_no_arms!((NonEmptyUnion2 { foo: () }));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: `NonEmptyUnion2` defined here
- --> $DIR/empty-match.rs:26:7
+ --> $DIR/empty-match.rs:27:11
|
-LL | union NonEmptyUnion2 {
- | ^^^^^^^^^^^^^^
+LL | union NonEmptyUnion2 {
+ | ^^^^^^^^^^^^^^
= note: the matched value is of type `NonEmptyUnion2`
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
error[E0004]: non-exhaustive patterns: `NonEmptyEnum1::Foo(_)` not covered
- --> $DIR/empty-match.rs:129:20
+ --> $DIR/empty-match.rs:51:20
|
LL | match_no_arms!(NonEmptyEnum1::Foo(true));
| ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyEnum1::Foo(_)` not covered
|
note: `NonEmptyEnum1` defined here
- --> $DIR/empty-match.rs:32:6
+ --> $DIR/empty-match.rs:31:10
|
-LL | enum NonEmptyEnum1 {
- | ^^^^^^^^^^^^^
-...
-LL | Foo(bool),
- | --- not covered
+LL | enum NonEmptyEnum1 {
+ | ^^^^^^^^^^^^^
+LL | Foo(bool),
+ | --- not covered
= note: the matched value is of type `NonEmptyEnum1`
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern
error[E0004]: non-exhaustive patterns: `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
- --> $DIR/empty-match.rs:132:20
+ --> $DIR/empty-match.rs:52:20
|
LL | match_no_arms!(NonEmptyEnum2::Foo(true));
| ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
|
note: `NonEmptyEnum2` defined here
- --> $DIR/empty-match.rs:39:6
- |
-LL | enum NonEmptyEnum2 {
- | ^^^^^^^^^^^^^
-...
-LL | Foo(bool),
- | --- not covered
-...
-LL | Bar,
- | --- not covered
+ --> $DIR/empty-match.rs:34:10
+ |
+LL | enum NonEmptyEnum2 {
+ | ^^^^^^^^^^^^^
+LL | Foo(bool),
+ | --- not covered
+LL | Bar,
+ | --- not covered
= note: the matched value is of type `NonEmptyEnum2`
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or multiple match arms
error[E0004]: non-exhaustive patterns: `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
- --> $DIR/empty-match.rs:135:20
+ --> $DIR/empty-match.rs:53:20
|
LL | match_no_arms!(NonEmptyEnum5::V1);
| ^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
|
note: `NonEmptyEnum5` defined here
- --> $DIR/empty-match.rs:49:6
- |
-LL | enum NonEmptyEnum5 {
- | ^^^^^^^^^^^^^
-...
-LL | V1, V2, V3, V4, V5,
- | -- -- -- -- -- not covered
- | | | | |
- | | | | not covered
- | | | not covered
- | | not covered
- | not covered
+ --> $DIR/empty-match.rs:38:10
+ |
+LL | enum NonEmptyEnum5 {
+ | ^^^^^^^^^^^^^
+LL | V1,
+ | -- not covered
+LL | V2,
+ | -- not covered
+LL | V3,
+ | -- not covered
+LL | V4,
+ | -- not covered
+LL | V5,
+ | -- not covered
= note: the matched value is of type `NonEmptyEnum5`
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or multiple match arms
error[E0004]: non-exhaustive patterns: `_` not covered
- --> $DIR/empty-match.rs:139:24
+ --> $DIR/empty-match.rs:55:24
|
LL | match_guarded_arm!(0u8);
| ^^^ pattern `_` not covered
@@ -189,161 +131,159 @@ LL | match_guarded_arm!(0u8);
= note: match arms with guards don't count towards exhaustivity
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
-LL ~ _ if false => {},
-LL + _ => todo!()
+LL ~ _ if false => {},
+LL + _ => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyStruct1` not covered
- --> $DIR/empty-match.rs:144:24
+ --> $DIR/empty-match.rs:56:24
|
LL | match_guarded_arm!(NonEmptyStruct1);
| ^^^^^^^^^^^^^^^ pattern `NonEmptyStruct1` not covered
|
note: `NonEmptyStruct1` defined here
- --> $DIR/empty-match.rs:15:8
+ --> $DIR/empty-match.rs:22:12
|
-LL | struct NonEmptyStruct1;
- | ^^^^^^^^^^^^^^^
+LL | struct NonEmptyStruct1;
+ | ^^^^^^^^^^^^^^^
= note: the matched value is of type `NonEmptyStruct1`
= note: match arms with guards don't count towards exhaustivity
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
-LL ~ _ if false => {},
-LL + NonEmptyStruct1 => todo!()
+LL ~ _ if false => {},
+LL + NonEmptyStruct1 => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyStruct2(_)` not covered
- --> $DIR/empty-match.rs:149:24
+ --> $DIR/empty-match.rs:57:24
|
LL | match_guarded_arm!(NonEmptyStruct2(true));
| ^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyStruct2(_)` not covered
|
note: `NonEmptyStruct2` defined here
- --> $DIR/empty-match.rs:18:8
+ --> $DIR/empty-match.rs:23:12
|
-LL | struct NonEmptyStruct2(bool);
- | ^^^^^^^^^^^^^^^
+LL | struct NonEmptyStruct2(bool);
+ | ^^^^^^^^^^^^^^^
= note: the matched value is of type `NonEmptyStruct2`
= note: match arms with guards don't count towards exhaustivity
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
-LL ~ _ if false => {},
-LL + NonEmptyStruct2(_) => todo!()
+LL ~ _ if false => {},
+LL + NonEmptyStruct2(_) => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyUnion1 { .. }` not covered
- --> $DIR/empty-match.rs:154:24
+ --> $DIR/empty-match.rs:58:24
|
LL | match_guarded_arm!((NonEmptyUnion1 { foo: () }));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion1 { .. }` not covered
|
note: `NonEmptyUnion1` defined here
- --> $DIR/empty-match.rs:21:7
+ --> $DIR/empty-match.rs:24:11
|
-LL | union NonEmptyUnion1 {
- | ^^^^^^^^^^^^^^
+LL | union NonEmptyUnion1 {
+ | ^^^^^^^^^^^^^^
= note: the matched value is of type `NonEmptyUnion1`
= note: match arms with guards don't count towards exhaustivity
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
-LL ~ _ if false => {},
-LL + NonEmptyUnion1 { .. } => todo!()
+LL ~ _ if false => {},
+LL + NonEmptyUnion1 { .. } => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyUnion2 { .. }` not covered
- --> $DIR/empty-match.rs:159:24
+ --> $DIR/empty-match.rs:59:24
|
LL | match_guarded_arm!((NonEmptyUnion2 { foo: () }));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion2 { .. }` not covered
|
note: `NonEmptyUnion2` defined here
- --> $DIR/empty-match.rs:26:7
+ --> $DIR/empty-match.rs:27:11
|
-LL | union NonEmptyUnion2 {
- | ^^^^^^^^^^^^^^
+LL | union NonEmptyUnion2 {
+ | ^^^^^^^^^^^^^^
= note: the matched value is of type `NonEmptyUnion2`
= note: match arms with guards don't count towards exhaustivity
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
-LL ~ _ if false => {},
-LL + NonEmptyUnion2 { .. } => todo!()
+LL ~ _ if false => {},
+LL + NonEmptyUnion2 { .. } => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyEnum1::Foo(_)` not covered
- --> $DIR/empty-match.rs:164:24
+ --> $DIR/empty-match.rs:60:24
|
LL | match_guarded_arm!(NonEmptyEnum1::Foo(true));
| ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyEnum1::Foo(_)` not covered
|
note: `NonEmptyEnum1` defined here
- --> $DIR/empty-match.rs:32:6
+ --> $DIR/empty-match.rs:31:10
|
-LL | enum NonEmptyEnum1 {
- | ^^^^^^^^^^^^^
-...
-LL | Foo(bool),
- | --- not covered
+LL | enum NonEmptyEnum1 {
+ | ^^^^^^^^^^^^^
+LL | Foo(bool),
+ | --- not covered
= note: the matched value is of type `NonEmptyEnum1`
= note: match arms with guards don't count towards exhaustivity
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
-LL ~ _ if false => {},
-LL + NonEmptyEnum1::Foo(_) => todo!()
+LL ~ _ if false => {},
+LL + NonEmptyEnum1::Foo(_) => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
- --> $DIR/empty-match.rs:169:24
+ --> $DIR/empty-match.rs:61:24
|
LL | match_guarded_arm!(NonEmptyEnum2::Foo(true));
| ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
|
note: `NonEmptyEnum2` defined here
- --> $DIR/empty-match.rs:39:6
- |
-LL | enum NonEmptyEnum2 {
- | ^^^^^^^^^^^^^
-...
-LL | Foo(bool),
- | --- not covered
-...
-LL | Bar,
- | --- not covered
+ --> $DIR/empty-match.rs:34:10
+ |
+LL | enum NonEmptyEnum2 {
+ | ^^^^^^^^^^^^^
+LL | Foo(bool),
+ | --- not covered
+LL | Bar,
+ | --- not covered
= note: the matched value is of type `NonEmptyEnum2`
= note: match arms with guards don't count towards exhaustivity
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
|
-LL ~ _ if false => {},
-LL + NonEmptyEnum2::Foo(_) | NonEmptyEnum2::Bar => todo!()
+LL ~ _ if false => {},
+LL + NonEmptyEnum2::Foo(_) | NonEmptyEnum2::Bar => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
- --> $DIR/empty-match.rs:174:24
+ --> $DIR/empty-match.rs:62:24
|
LL | match_guarded_arm!(NonEmptyEnum5::V1);
| ^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
|
note: `NonEmptyEnum5` defined here
- --> $DIR/empty-match.rs:49:6
- |
-LL | enum NonEmptyEnum5 {
- | ^^^^^^^^^^^^^
-...
-LL | V1, V2, V3, V4, V5,
- | -- -- -- -- -- not covered
- | | | | |
- | | | | not covered
- | | | not covered
- | | not covered
- | not covered
+ --> $DIR/empty-match.rs:38:10
+ |
+LL | enum NonEmptyEnum5 {
+ | ^^^^^^^^^^^^^
+LL | V1,
+ | -- not covered
+LL | V2,
+ | -- not covered
+LL | V3,
+ | -- not covered
+LL | V4,
+ | -- not covered
+LL | V5,
+ | -- not covered
= note: the matched value is of type `NonEmptyEnum5`
= note: match arms with guards don't count towards exhaustivity
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms
|
-LL ~ _ if false => {},
-LL + _ => todo!()
+LL ~ _ if false => {},
+LL + _ => todo!()
|
-error: aborting due to 23 previous errors
+error: aborting due to 16 previous errors
-Some errors have detailed explanations: E0004, E0005.
-For more information about an error, try `rustc --explain E0004`.
+For more information about this error, try `rustc --explain E0004`.
diff --git a/tests/ui/pattern/usefulness/empty-match.normal.stderr b/tests/ui/pattern/usefulness/empty-match.normal.stderr
index 7f0389f40..9c3bebd77 100644
--- a/tests/ui/pattern/usefulness/empty-match.normal.stderr
+++ b/tests/ui/pattern/usefulness/empty-match.normal.stderr
@@ -1,61 +1,5 @@
-error: unreachable pattern
- --> $DIR/empty-match.rs:68:9
- |
-LL | _ => {},
- | ^
- |
-note: the lint level is defined here
- --> $DIR/empty-match.rs:8:9
- |
-LL | #![deny(unreachable_patterns)]
- | ^^^^^^^^^^^^^^^^^^^^
-
-error: unreachable pattern
- --> $DIR/empty-match.rs:71:9
- |
-LL | _ if false => {},
- | ^
-
-error: unreachable pattern
- --> $DIR/empty-match.rs:78:9
- |
-LL | _ => {},
- | ^
-
-error: unreachable pattern
- --> $DIR/empty-match.rs:81:9
- |
-LL | _ if false => {},
- | ^
-
-error[E0005]: refutable pattern in local binding
- --> $DIR/empty-match.rs:86:9
- |
-LL | let None = x;
- | ^^^^ pattern `Some(_)` not covered
- |
- = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
- = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
- = note: the matched value is of type `Option<SecretlyUninhabitedForeignStruct>`
-help: you might want to use `if let` to ignore the variant that isn't matched
- |
-LL | if let None = x { todo!() };
- | ++ +++++++++++
-
-error: unreachable pattern
- --> $DIR/empty-match.rs:98:9
- |
-LL | _ => {},
- | ^
-
-error: unreachable pattern
- --> $DIR/empty-match.rs:101:9
- |
-LL | _ if false => {},
- | ^
-
error[E0004]: non-exhaustive patterns: type `u8` is non-empty
- --> $DIR/empty-match.rs:119:20
+ --> $DIR/empty-match.rs:46:20
|
LL | match_no_arms!(0u8);
| ^^^
@@ -64,122 +8,121 @@ LL | match_no_arms!(0u8);
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
error[E0004]: non-exhaustive patterns: type `NonEmptyStruct1` is non-empty
- --> $DIR/empty-match.rs:121:20
+ --> $DIR/empty-match.rs:47:20
|
LL | match_no_arms!(NonEmptyStruct1);
| ^^^^^^^^^^^^^^^
|
note: `NonEmptyStruct1` defined here
- --> $DIR/empty-match.rs:15:8
+ --> $DIR/empty-match.rs:22:12
|
-LL | struct NonEmptyStruct1;
- | ^^^^^^^^^^^^^^^
+LL | struct NonEmptyStruct1;
+ | ^^^^^^^^^^^^^^^
= note: the matched value is of type `NonEmptyStruct1`
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
error[E0004]: non-exhaustive patterns: type `NonEmptyStruct2` is non-empty
- --> $DIR/empty-match.rs:123:20
+ --> $DIR/empty-match.rs:48:20
|
LL | match_no_arms!(NonEmptyStruct2(true));
| ^^^^^^^^^^^^^^^^^^^^^
|
note: `NonEmptyStruct2` defined here
- --> $DIR/empty-match.rs:18:8
+ --> $DIR/empty-match.rs:23:12
|
-LL | struct NonEmptyStruct2(bool);
- | ^^^^^^^^^^^^^^^
+LL | struct NonEmptyStruct2(bool);
+ | ^^^^^^^^^^^^^^^
= note: the matched value is of type `NonEmptyStruct2`
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
error[E0004]: non-exhaustive patterns: type `NonEmptyUnion1` is non-empty
- --> $DIR/empty-match.rs:125:20
+ --> $DIR/empty-match.rs:49:20
|
LL | match_no_arms!((NonEmptyUnion1 { foo: () }));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: `NonEmptyUnion1` defined here
- --> $DIR/empty-match.rs:21:7
+ --> $DIR/empty-match.rs:24:11
|
-LL | union NonEmptyUnion1 {
- | ^^^^^^^^^^^^^^
+LL | union NonEmptyUnion1 {
+ | ^^^^^^^^^^^^^^
= note: the matched value is of type `NonEmptyUnion1`
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
error[E0004]: non-exhaustive patterns: type `NonEmptyUnion2` is non-empty
- --> $DIR/empty-match.rs:127:20
+ --> $DIR/empty-match.rs:50:20
|
LL | match_no_arms!((NonEmptyUnion2 { foo: () }));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: `NonEmptyUnion2` defined here
- --> $DIR/empty-match.rs:26:7
+ --> $DIR/empty-match.rs:27:11
|
-LL | union NonEmptyUnion2 {
- | ^^^^^^^^^^^^^^
+LL | union NonEmptyUnion2 {
+ | ^^^^^^^^^^^^^^
= note: the matched value is of type `NonEmptyUnion2`
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
error[E0004]: non-exhaustive patterns: `NonEmptyEnum1::Foo(_)` not covered
- --> $DIR/empty-match.rs:129:20
+ --> $DIR/empty-match.rs:51:20
|
LL | match_no_arms!(NonEmptyEnum1::Foo(true));
| ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyEnum1::Foo(_)` not covered
|
note: `NonEmptyEnum1` defined here
- --> $DIR/empty-match.rs:32:6
+ --> $DIR/empty-match.rs:31:10
|
-LL | enum NonEmptyEnum1 {
- | ^^^^^^^^^^^^^
-...
-LL | Foo(bool),
- | --- not covered
+LL | enum NonEmptyEnum1 {
+ | ^^^^^^^^^^^^^
+LL | Foo(bool),
+ | --- not covered
= note: the matched value is of type `NonEmptyEnum1`
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern
error[E0004]: non-exhaustive patterns: `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
- --> $DIR/empty-match.rs:132:20
+ --> $DIR/empty-match.rs:52:20
|
LL | match_no_arms!(NonEmptyEnum2::Foo(true));
| ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
|
note: `NonEmptyEnum2` defined here
- --> $DIR/empty-match.rs:39:6
- |
-LL | enum NonEmptyEnum2 {
- | ^^^^^^^^^^^^^
-...
-LL | Foo(bool),
- | --- not covered
-...
-LL | Bar,
- | --- not covered
+ --> $DIR/empty-match.rs:34:10
+ |
+LL | enum NonEmptyEnum2 {
+ | ^^^^^^^^^^^^^
+LL | Foo(bool),
+ | --- not covered
+LL | Bar,
+ | --- not covered
= note: the matched value is of type `NonEmptyEnum2`
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or multiple match arms
error[E0004]: non-exhaustive patterns: `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
- --> $DIR/empty-match.rs:135:20
+ --> $DIR/empty-match.rs:53:20
|
LL | match_no_arms!(NonEmptyEnum5::V1);
| ^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
|
note: `NonEmptyEnum5` defined here
- --> $DIR/empty-match.rs:49:6
- |
-LL | enum NonEmptyEnum5 {
- | ^^^^^^^^^^^^^
-...
-LL | V1, V2, V3, V4, V5,
- | -- -- -- -- -- not covered
- | | | | |
- | | | | not covered
- | | | not covered
- | | not covered
- | not covered
+ --> $DIR/empty-match.rs:38:10
+ |
+LL | enum NonEmptyEnum5 {
+ | ^^^^^^^^^^^^^
+LL | V1,
+ | -- not covered
+LL | V2,
+ | -- not covered
+LL | V3,
+ | -- not covered
+LL | V4,
+ | -- not covered
+LL | V5,
+ | -- not covered
= note: the matched value is of type `NonEmptyEnum5`
= help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or multiple match arms
error[E0004]: non-exhaustive patterns: `_` not covered
- --> $DIR/empty-match.rs:139:24
+ --> $DIR/empty-match.rs:55:24
|
LL | match_guarded_arm!(0u8);
| ^^^ pattern `_` not covered
@@ -188,161 +131,159 @@ LL | match_guarded_arm!(0u8);
= note: match arms with guards don't count towards exhaustivity
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
-LL ~ _ if false => {},
-LL + _ => todo!()
+LL ~ _ if false => {},
+LL + _ => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyStruct1` not covered
- --> $DIR/empty-match.rs:144:24
+ --> $DIR/empty-match.rs:56:24
|
LL | match_guarded_arm!(NonEmptyStruct1);
| ^^^^^^^^^^^^^^^ pattern `NonEmptyStruct1` not covered
|
note: `NonEmptyStruct1` defined here
- --> $DIR/empty-match.rs:15:8
+ --> $DIR/empty-match.rs:22:12
|
-LL | struct NonEmptyStruct1;
- | ^^^^^^^^^^^^^^^
+LL | struct NonEmptyStruct1;
+ | ^^^^^^^^^^^^^^^
= note: the matched value is of type `NonEmptyStruct1`
= note: match arms with guards don't count towards exhaustivity
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
-LL ~ _ if false => {},
-LL + NonEmptyStruct1 => todo!()
+LL ~ _ if false => {},
+LL + NonEmptyStruct1 => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyStruct2(_)` not covered
- --> $DIR/empty-match.rs:149:24
+ --> $DIR/empty-match.rs:57:24
|
LL | match_guarded_arm!(NonEmptyStruct2(true));
| ^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyStruct2(_)` not covered
|
note: `NonEmptyStruct2` defined here
- --> $DIR/empty-match.rs:18:8
+ --> $DIR/empty-match.rs:23:12
|
-LL | struct NonEmptyStruct2(bool);
- | ^^^^^^^^^^^^^^^
+LL | struct NonEmptyStruct2(bool);
+ | ^^^^^^^^^^^^^^^
= note: the matched value is of type `NonEmptyStruct2`
= note: match arms with guards don't count towards exhaustivity
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
-LL ~ _ if false => {},
-LL + NonEmptyStruct2(_) => todo!()
+LL ~ _ if false => {},
+LL + NonEmptyStruct2(_) => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyUnion1 { .. }` not covered
- --> $DIR/empty-match.rs:154:24
+ --> $DIR/empty-match.rs:58:24
|
LL | match_guarded_arm!((NonEmptyUnion1 { foo: () }));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion1 { .. }` not covered
|
note: `NonEmptyUnion1` defined here
- --> $DIR/empty-match.rs:21:7
+ --> $DIR/empty-match.rs:24:11
|
-LL | union NonEmptyUnion1 {
- | ^^^^^^^^^^^^^^
+LL | union NonEmptyUnion1 {
+ | ^^^^^^^^^^^^^^
= note: the matched value is of type `NonEmptyUnion1`
= note: match arms with guards don't count towards exhaustivity
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
-LL ~ _ if false => {},
-LL + NonEmptyUnion1 { .. } => todo!()
+LL ~ _ if false => {},
+LL + NonEmptyUnion1 { .. } => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyUnion2 { .. }` not covered
- --> $DIR/empty-match.rs:159:24
+ --> $DIR/empty-match.rs:59:24
|
LL | match_guarded_arm!((NonEmptyUnion2 { foo: () }));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion2 { .. }` not covered
|
note: `NonEmptyUnion2` defined here
- --> $DIR/empty-match.rs:26:7
+ --> $DIR/empty-match.rs:27:11
|
-LL | union NonEmptyUnion2 {
- | ^^^^^^^^^^^^^^
+LL | union NonEmptyUnion2 {
+ | ^^^^^^^^^^^^^^
= note: the matched value is of type `NonEmptyUnion2`
= note: match arms with guards don't count towards exhaustivity
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
-LL ~ _ if false => {},
-LL + NonEmptyUnion2 { .. } => todo!()
+LL ~ _ if false => {},
+LL + NonEmptyUnion2 { .. } => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyEnum1::Foo(_)` not covered
- --> $DIR/empty-match.rs:164:24
+ --> $DIR/empty-match.rs:60:24
|
LL | match_guarded_arm!(NonEmptyEnum1::Foo(true));
| ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyEnum1::Foo(_)` not covered
|
note: `NonEmptyEnum1` defined here
- --> $DIR/empty-match.rs:32:6
+ --> $DIR/empty-match.rs:31:10
|
-LL | enum NonEmptyEnum1 {
- | ^^^^^^^^^^^^^
-...
-LL | Foo(bool),
- | --- not covered
+LL | enum NonEmptyEnum1 {
+ | ^^^^^^^^^^^^^
+LL | Foo(bool),
+ | --- not covered
= note: the matched value is of type `NonEmptyEnum1`
= note: match arms with guards don't count towards exhaustivity
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
-LL ~ _ if false => {},
-LL + NonEmptyEnum1::Foo(_) => todo!()
+LL ~ _ if false => {},
+LL + NonEmptyEnum1::Foo(_) => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
- --> $DIR/empty-match.rs:169:24
+ --> $DIR/empty-match.rs:61:24
|
LL | match_guarded_arm!(NonEmptyEnum2::Foo(true));
| ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
|
note: `NonEmptyEnum2` defined here
- --> $DIR/empty-match.rs:39:6
- |
-LL | enum NonEmptyEnum2 {
- | ^^^^^^^^^^^^^
-...
-LL | Foo(bool),
- | --- not covered
-...
-LL | Bar,
- | --- not covered
+ --> $DIR/empty-match.rs:34:10
+ |
+LL | enum NonEmptyEnum2 {
+ | ^^^^^^^^^^^^^
+LL | Foo(bool),
+ | --- not covered
+LL | Bar,
+ | --- not covered
= note: the matched value is of type `NonEmptyEnum2`
= note: match arms with guards don't count towards exhaustivity
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
|
-LL ~ _ if false => {},
-LL + NonEmptyEnum2::Foo(_) | NonEmptyEnum2::Bar => todo!()
+LL ~ _ if false => {},
+LL + NonEmptyEnum2::Foo(_) | NonEmptyEnum2::Bar => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
- --> $DIR/empty-match.rs:174:24
+ --> $DIR/empty-match.rs:62:24
|
LL | match_guarded_arm!(NonEmptyEnum5::V1);
| ^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
|
note: `NonEmptyEnum5` defined here
- --> $DIR/empty-match.rs:49:6
- |
-LL | enum NonEmptyEnum5 {
- | ^^^^^^^^^^^^^
-...
-LL | V1, V2, V3, V4, V5,
- | -- -- -- -- -- not covered
- | | | | |
- | | | | not covered
- | | | not covered
- | | not covered
- | not covered
+ --> $DIR/empty-match.rs:38:10
+ |
+LL | enum NonEmptyEnum5 {
+ | ^^^^^^^^^^^^^
+LL | V1,
+ | -- not covered
+LL | V2,
+ | -- not covered
+LL | V3,
+ | -- not covered
+LL | V4,
+ | -- not covered
+LL | V5,
+ | -- not covered
= note: the matched value is of type `NonEmptyEnum5`
= note: match arms with guards don't count towards exhaustivity
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms
|
-LL ~ _ if false => {},
-LL + _ => todo!()
+LL ~ _ if false => {},
+LL + _ => todo!()
|
-error: aborting due to 23 previous errors
+error: aborting due to 16 previous errors
-Some errors have detailed explanations: E0004, E0005.
-For more information about an error, try `rustc --explain E0004`.
+For more information about this error, try `rustc --explain E0004`.
diff --git a/tests/ui/pattern/usefulness/empty-match.rs b/tests/ui/pattern/usefulness/empty-match.rs
index fe5d0bce1..321f24adc 100644
--- a/tests/ui/pattern/usefulness/empty-match.rs
+++ b/tests/ui/pattern/usefulness/empty-match.rs
@@ -1,179 +1,65 @@
-// aux-build:empty.rs
// revisions: normal exhaustive_patterns
//
// This tests a match with no arms on various types.
#![feature(never_type)]
-#![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 {
- //~^ NOTE `NonEmptyEnum1` defined here
- //~| NOTE `NonEmptyEnum1` defined here
- Foo(bool),
- //~^ NOTE not covered
- //~| NOTE not covered
-}
-enum NonEmptyEnum2 {
- //~^ NOTE `NonEmptyEnum2` defined here
- //~| NOTE `NonEmptyEnum2` defined here
- Foo(bool),
- //~^ 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,
- //~^ NOTE not covered
- //~| NOTE not covered
- //~| NOTE not covered
- //~| NOTE not covered
- //~| NOTE not covered
- //~| NOTE not covered
- //~| NOTE not covered
- //~| NOTE not covered
- //~| NOTE not covered
- //~| NOTE not covered
-}
-
-fn empty_enum(x: EmptyEnum) {
- match x {} // ok
- match x {
- _ => {}, //~ ERROR unreachable pattern
+fn nonempty() {
+ macro_rules! match_no_arms {
+ ($e:expr) => {
+ match $e {}
+ };
}
- match x {
- _ if false => {}, //~ ERROR unreachable pattern
+ macro_rules! match_guarded_arm {
+ ($e:expr) => {
+ match $e {
+ _ if false => {}
+ }
+ };
}
-}
-fn empty_foreign_enum(x: empty::EmptyForeignEnum) {
- match x {} // ok
- match x {
- _ => {}, //~ ERROR unreachable pattern
+ struct NonEmptyStruct1;
+ struct NonEmptyStruct2(bool);
+ union NonEmptyUnion1 {
+ foo: (),
}
- match x {
- _ if false => {}, //~ ERROR unreachable pattern
+ union NonEmptyUnion2 {
+ foo: (),
+ bar: !,
}
-}
-
-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 {
- _ => {}, //~ ERROR unreachable pattern
+ enum NonEmptyEnum1 {
+ Foo(bool),
}
- match x {
- _ if false => {}, //~ ERROR unreachable pattern
+ enum NonEmptyEnum2 {
+ Foo(bool),
+ Bar,
+ }
+ enum NonEmptyEnum5 {
+ V1,
+ V2,
+ V3,
+ V4,
+ V5,
}
-}
-
-macro_rules! match_no_arms {
- ($e:expr) => {
- match $e {}
- };
-}
-macro_rules! match_guarded_arm {
- ($e:expr) => {
- match $e {
- _ if false => {}
- }
- };
-}
-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 match arms with guards don't count towards exhaustivity
- //~| 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 match arms with guards don't count towards exhaustivity
- //~| 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 match arms with guards don't count towards exhaustivity
- //~| 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 match arms with guards don't count towards exhaustivity
- //~| 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 match arms with guards don't count towards exhaustivity
- //~| 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 match arms with guards don't count towards exhaustivity
- //~| 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 match arms with guards don't count towards exhaustivity
- //~| 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 match arms with guards don't count towards exhaustivity
- //~| NOTE in this expansion of match_guarded_arm!
}
+
+fn main() {}
diff --git a/tests/ui/pattern/usefulness/empty-types.exhaustive_patterns.stderr b/tests/ui/pattern/usefulness/empty-types.exhaustive_patterns.stderr
new file mode 100644
index 000000000..367aba3bd
--- /dev/null
+++ b/tests/ui/pattern/usefulness/empty-types.exhaustive_patterns.stderr
@@ -0,0 +1,393 @@
+error: unreachable pattern
+ --> $DIR/empty-types.rs:47:9
+ |
+LL | _ => {}
+ | ^
+ |
+note: the lint level is defined here
+ --> $DIR/empty-types.rs:13:9
+ |
+LL | #![deny(unreachable_patterns)]
+ | ^^^^^^^^^^^^^^^^^^^^
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:50:9
+ |
+LL | _x => {}
+ | ^^
+
+error[E0004]: non-exhaustive patterns: type `&!` is non-empty
+ --> $DIR/empty-types.rs:54:11
+ |
+LL | match ref_never {}
+ | ^^^^^^^^^
+ |
+ = note: the matched value is of type `&!`
+ = note: references are always considered inhabited
+help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
+ |
+LL ~ match ref_never {
+LL + _ => todo!(),
+LL + }
+ |
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:69:9
+ |
+LL | (_, _) => {}
+ | ^^^^^^
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:76:9
+ |
+LL | _ => {}
+ | ^
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:79:9
+ |
+LL | (_, _) => {}
+ | ^^^^^^
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:83:9
+ |
+LL | _ => {}
+ | ^
+
+error[E0004]: non-exhaustive patterns: `Ok(_)` not covered
+ --> $DIR/empty-types.rs:87:11
+ |
+LL | match res_u32_never {}
+ | ^^^^^^^^^^^^^ pattern `Ok(_)` not covered
+ |
+note: `Result<u32, !>` defined here
+ --> $SRC_DIR/core/src/result.rs:LL:COL
+ ::: $SRC_DIR/core/src/result.rs:LL:COL
+ |
+ = note: not covered
+ = note: the matched value is of type `Result<u32, !>`
+help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
+ |
+LL ~ match res_u32_never {
+LL + Ok(_) => todo!(),
+LL + }
+ |
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:95:9
+ |
+LL | Err(_) => {}
+ | ^^^^^^
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:100:9
+ |
+LL | Err(_) => {}
+ | ^^^^^^
+
+error[E0004]: non-exhaustive patterns: `Ok(1_u32..=u32::MAX)` not covered
+ --> $DIR/empty-types.rs:97:11
+ |
+LL | match res_u32_never {
+ | ^^^^^^^^^^^^^ pattern `Ok(1_u32..=u32::MAX)` not covered
+ |
+note: `Result<u32, !>` defined here
+ --> $SRC_DIR/core/src/result.rs:LL:COL
+ ::: $SRC_DIR/core/src/result.rs:LL:COL
+ |
+ = note: not covered
+ = note: the matched value is of type `Result<u32, !>`
+help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
+ |
+LL ~ Err(_) => {},
+LL ~ Ok(1_u32..=u32::MAX) => todo!()
+ |
+
+error[E0005]: refutable pattern in local binding
+ --> $DIR/empty-types.rs:104:9
+ |
+LL | let Ok(_x) = res_u32_never.as_ref();
+ | ^^^^^^ pattern `Err(_)` not covered
+ |
+ = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
+ = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
+ = note: the matched value is of type `Result<&u32, &!>`
+help: you might want to use `let else` to handle the variant that isn't matched
+ |
+LL | let Ok(_x) = res_u32_never.as_ref() else { todo!() };
+ | ++++++++++++++++
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:115:9
+ |
+LL | _ => {}
+ | ^
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:119:9
+ |
+LL | Ok(_) => {}
+ | ^^^^^
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:122:9
+ |
+LL | Ok(_) => {}
+ | ^^^^^
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:123:9
+ |
+LL | _ => {}
+ | ^
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:126:9
+ |
+LL | Ok(_) => {}
+ | ^^^^^
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:127:9
+ |
+LL | Err(_) => {}
+ | ^^^^^^
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:136:13
+ |
+LL | _ => {}
+ | ^
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:139:13
+ |
+LL | _ if false => {}
+ | ^
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:148:13
+ |
+LL | Some(_) => {}
+ | ^^^^^^^
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:152:13
+ |
+LL | _ => {}
+ | ^
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:204:13
+ |
+LL | _ => {}
+ | ^
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:209:13
+ |
+LL | _ => {}
+ | ^
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:214:13
+ |
+LL | _ => {}
+ | ^
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:219:13
+ |
+LL | _ => {}
+ | ^
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:225:13
+ |
+LL | _ => {}
+ | ^
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:284:9
+ |
+LL | _ => {}
+ | ^
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:287:9
+ |
+LL | (_, _) => {}
+ | ^^^^^^
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:290:9
+ |
+LL | Ok(_) => {}
+ | ^^^^^
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:291:9
+ |
+LL | Err(_) => {}
+ | ^^^^^^
+
+error[E0004]: non-exhaustive patterns: type `&[!]` is non-empty
+ --> $DIR/empty-types.rs:323:11
+ |
+LL | match slice_never {}
+ | ^^^^^^^^^^^
+ |
+ = note: the matched value is of type `&[!]`
+help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
+ |
+LL ~ match slice_never {
+LL + _ => todo!(),
+LL + }
+ |
+
+error[E0004]: non-exhaustive patterns: `&[]` not covered
+ --> $DIR/empty-types.rs:334:11
+ |
+LL | match slice_never {
+ | ^^^^^^^^^^^ pattern `&[]` not covered
+ |
+ = note: the matched value is of type `&[!]`
+help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
+ |
+LL ~ [_, _, _, ..] => {},
+LL + &[] => todo!()
+ |
+
+error[E0004]: non-exhaustive patterns: `&[]` not covered
+ --> $DIR/empty-types.rs:347:11
+ |
+LL | match slice_never {
+ | ^^^^^^^^^^^ pattern `&[]` not covered
+ |
+ = note: the matched value is of type `&[!]`
+ = note: match arms with guards don't count towards exhaustivity
+help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
+ |
+LL ~ &[..] if false => {},
+LL + &[] => todo!()
+ |
+
+error[E0004]: non-exhaustive patterns: type `[!]` is non-empty
+ --> $DIR/empty-types.rs:353:11
+ |
+LL | match *slice_never {}
+ | ^^^^^^^^^^^^
+ |
+ = note: the matched value is of type `[!]`
+help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
+ |
+LL ~ match *slice_never {
+LL + _ => todo!(),
+LL + }
+ |
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:363:9
+ |
+LL | _ => {}
+ | ^
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:366:9
+ |
+LL | [_, _, _] => {}
+ | ^^^^^^^^^
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:369:9
+ |
+LL | [_, ..] => {}
+ | ^^^^^^^
+
+error[E0004]: non-exhaustive patterns: type `[!; 0]` is non-empty
+ --> $DIR/empty-types.rs:383:11
+ |
+LL | match array_0_never {}
+ | ^^^^^^^^^^^^^
+ |
+ = note: the matched value is of type `[!; 0]`
+help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
+ |
+LL ~ match array_0_never {
+LL + _ => todo!(),
+LL + }
+ |
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:390:9
+ |
+LL | _ => {}
+ | ^
+
+error[E0004]: non-exhaustive patterns: `[]` not covered
+ --> $DIR/empty-types.rs:392:11
+ |
+LL | match array_0_never {
+ | ^^^^^^^^^^^^^ pattern `[]` not covered
+ |
+ = note: the matched value is of type `[!; 0]`
+ = note: match arms with guards don't count towards exhaustivity
+help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
+ |
+LL ~ [..] if false => {},
+LL + [] => todo!()
+ |
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:411:9
+ |
+LL | Some(_) => {}
+ | ^^^^^^^
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:416:9
+ |
+LL | Some(_a) => {}
+ | ^^^^^^^^
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:421:9
+ |
+LL | _ => {}
+ | ^
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:426:9
+ |
+LL | _a => {}
+ | ^^
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:598:9
+ |
+LL | _ => {}
+ | ^
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:601:9
+ |
+LL | _x => {}
+ | ^^
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:604:9
+ |
+LL | _ if false => {}
+ | ^
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:607:9
+ |
+LL | _x if false => {}
+ | ^^
+
+error: aborting due to 49 previous errors
+
+Some errors have detailed explanations: E0004, E0005.
+For more information about an error, try `rustc --explain E0004`.
diff --git a/tests/ui/pattern/usefulness/empty-types.normal.stderr b/tests/ui/pattern/usefulness/empty-types.normal.stderr
new file mode 100644
index 000000000..133a95a82
--- /dev/null
+++ b/tests/ui/pattern/usefulness/empty-types.normal.stderr
@@ -0,0 +1,617 @@
+error: unreachable pattern
+ --> $DIR/empty-types.rs:47:9
+ |
+LL | _ => {}
+ | ^
+ |
+note: the lint level is defined here
+ --> $DIR/empty-types.rs:13:9
+ |
+LL | #![deny(unreachable_patterns)]
+ | ^^^^^^^^^^^^^^^^^^^^
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:50:9
+ |
+LL | _x => {}
+ | ^^
+
+error[E0004]: non-exhaustive patterns: type `&!` is non-empty
+ --> $DIR/empty-types.rs:54:11
+ |
+LL | match ref_never {}
+ | ^^^^^^^^^
+ |
+ = note: the matched value is of type `&!`
+ = note: references are always considered inhabited
+help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
+ |
+LL ~ match ref_never {
+LL + _ => todo!(),
+LL + }
+ |
+
+error[E0004]: non-exhaustive patterns: type `(u32, !)` is non-empty
+ --> $DIR/empty-types.rs:66:11
+ |
+LL | match tuple_half_never {}
+ | ^^^^^^^^^^^^^^^^
+ |
+ = note: the matched value is of type `(u32, !)`
+help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
+ |
+LL ~ match tuple_half_never {
+LL + _ => todo!(),
+LL + }
+ |
+
+error[E0004]: non-exhaustive patterns: type `(!, !)` is non-empty
+ --> $DIR/empty-types.rs:73:11
+ |
+LL | match tuple_never {}
+ | ^^^^^^^^^^^
+ |
+ = note: the matched value is of type `(!, !)`
+help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
+ |
+LL ~ match tuple_never {
+LL + _ => todo!(),
+LL + }
+ |
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:83:9
+ |
+LL | _ => {}
+ | ^
+
+error[E0004]: non-exhaustive patterns: `Ok(_)` and `Err(_)` not covered
+ --> $DIR/empty-types.rs:87:11
+ |
+LL | match res_u32_never {}
+ | ^^^^^^^^^^^^^ patterns `Ok(_)` and `Err(_)` not covered
+ |
+note: `Result<u32, !>` defined here
+ --> $SRC_DIR/core/src/result.rs:LL:COL
+ ::: $SRC_DIR/core/src/result.rs:LL:COL
+ |
+ = note: not covered
+ ::: $SRC_DIR/core/src/result.rs:LL:COL
+ |
+ = note: not covered
+ = note: the matched value is of type `Result<u32, !>`
+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
+ |
+LL ~ match res_u32_never {
+LL + Ok(_) | Err(_) => todo!(),
+LL + }
+ |
+
+error[E0004]: non-exhaustive patterns: `Err(_)` not covered
+ --> $DIR/empty-types.rs:89:11
+ |
+LL | match res_u32_never {
+ | ^^^^^^^^^^^^^ pattern `Err(_)` not covered
+ |
+note: `Result<u32, !>` defined here
+ --> $SRC_DIR/core/src/result.rs:LL:COL
+ ::: $SRC_DIR/core/src/result.rs:LL:COL
+ |
+ = note: not covered
+ = note: the matched value is of type `Result<u32, !>`
+help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
+ |
+LL ~ Ok(_) => {},
+LL + Err(_) => todo!()
+ |
+
+error[E0004]: non-exhaustive patterns: `Ok(1_u32..=u32::MAX)` not covered
+ --> $DIR/empty-types.rs:97:11
+ |
+LL | match res_u32_never {
+ | ^^^^^^^^^^^^^ pattern `Ok(1_u32..=u32::MAX)` not covered
+ |
+note: `Result<u32, !>` defined here
+ --> $SRC_DIR/core/src/result.rs:LL:COL
+ ::: $SRC_DIR/core/src/result.rs:LL:COL
+ |
+ = note: not covered
+ = note: the matched value is of type `Result<u32, !>`
+help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
+ |
+LL ~ Err(_) => {},
+LL ~ Ok(1_u32..=u32::MAX) => todo!()
+ |
+
+error[E0005]: refutable pattern in local binding
+ --> $DIR/empty-types.rs:102:9
+ |
+LL | let Ok(_x) = res_u32_never;
+ | ^^^^^^ pattern `Err(_)` not covered
+ |
+ = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
+ = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
+ = note: the matched value is of type `Result<u32, !>`
+help: you might want to use `let else` to handle the variant that isn't matched
+ |
+LL | let Ok(_x) = res_u32_never else { todo!() };
+ | ++++++++++++++++
+
+error[E0005]: refutable pattern in local binding
+ --> $DIR/empty-types.rs:104:9
+ |
+LL | let Ok(_x) = res_u32_never.as_ref();
+ | ^^^^^^ pattern `Err(_)` not covered
+ |
+ = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
+ = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
+ = note: the matched value is of type `Result<&u32, &!>`
+help: you might want to use `let else` to handle the variant that isn't matched
+ |
+LL | let Ok(_x) = res_u32_never.as_ref() else { todo!() };
+ | ++++++++++++++++
+
+error[E0005]: refutable pattern in local binding
+ --> $DIR/empty-types.rs:108:9
+ |
+LL | let Ok(_x) = &res_u32_never;
+ | ^^^^^^ pattern `&Err(_)` not covered
+ |
+ = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
+ = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
+ = note: the matched value is of type `&Result<u32, !>`
+help: you might want to use `let else` to handle the variant that isn't matched
+ |
+LL | let Ok(_x) = &res_u32_never else { todo!() };
+ | ++++++++++++++++
+
+error[E0004]: non-exhaustive patterns: `Ok(_)` and `Err(_)` not covered
+ --> $DIR/empty-types.rs:112:11
+ |
+LL | match result_never {}
+ | ^^^^^^^^^^^^ patterns `Ok(_)` and `Err(_)` not covered
+ |
+note: `Result<!, !>` defined here
+ --> $SRC_DIR/core/src/result.rs:LL:COL
+ ::: $SRC_DIR/core/src/result.rs:LL:COL
+ |
+ = note: not covered
+ ::: $SRC_DIR/core/src/result.rs:LL:COL
+ |
+ = note: not covered
+ = note: the matched value is of type `Result<!, !>`
+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
+ |
+LL ~ match result_never {
+LL + Ok(_) | Err(_) => todo!(),
+LL + }
+ |
+
+error[E0004]: non-exhaustive patterns: `Err(_)` not covered
+ --> $DIR/empty-types.rs:117:11
+ |
+LL | match result_never {
+ | ^^^^^^^^^^^^ pattern `Err(_)` not covered
+ |
+note: `Result<!, !>` defined here
+ --> $SRC_DIR/core/src/result.rs:LL:COL
+ ::: $SRC_DIR/core/src/result.rs:LL:COL
+ |
+ = note: not covered
+ = note: the matched value is of type `Result<!, !>`
+help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
+ |
+LL | Ok(_) => {}, Err(_) => todo!()
+ | +++++++++++++++++++
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:136:13
+ |
+LL | _ => {}
+ | ^
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:139:13
+ |
+LL | _ if false => {}
+ | ^
+
+error[E0004]: non-exhaustive patterns: `Some(_)` not covered
+ --> $DIR/empty-types.rs:142:15
+ |
+LL | match opt_void {
+ | ^^^^^^^^ pattern `Some(_)` not covered
+ |
+note: `Option<Void>` defined here
+ --> $SRC_DIR/core/src/option.rs:LL:COL
+ ::: $SRC_DIR/core/src/option.rs:LL:COL
+ |
+ = note: not covered
+ = note: the matched value is of type `Option<Void>`
+help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
+ |
+LL ~ None => {},
+LL + Some(_) => todo!()
+ |
+
+error[E0004]: non-exhaustive patterns: `Some(_)` not covered
+ --> $DIR/empty-types.rs:161:15
+ |
+LL | match *ref_opt_void {
+ | ^^^^^^^^^^^^^ pattern `Some(_)` not covered
+ |
+note: `Option<Void>` defined here
+ --> $SRC_DIR/core/src/option.rs:LL:COL
+ ::: $SRC_DIR/core/src/option.rs:LL:COL
+ |
+ = note: not covered
+ = note: the matched value is of type `Option<Void>`
+help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
+ |
+LL ~ None => {},
+LL + Some(_) => todo!()
+ |
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:204:13
+ |
+LL | _ => {}
+ | ^
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:209:13
+ |
+LL | _ => {}
+ | ^
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:214:13
+ |
+LL | _ => {}
+ | ^
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:219:13
+ |
+LL | _ => {}
+ | ^
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:225:13
+ |
+LL | _ => {}
+ | ^
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:284:9
+ |
+LL | _ => {}
+ | ^
+
+error[E0004]: non-exhaustive patterns: type `(u32, !)` is non-empty
+ --> $DIR/empty-types.rs:312:11
+ |
+LL | match *x {}
+ | ^^
+ |
+ = note: the matched value is of type `(u32, !)`
+help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
+ |
+LL ~ match *x {
+LL + _ => todo!(),
+LL ~ }
+ |
+
+error[E0004]: non-exhaustive patterns: type `(!, !)` is non-empty
+ --> $DIR/empty-types.rs:314:11
+ |
+LL | match *x {}
+ | ^^
+ |
+ = note: the matched value is of type `(!, !)`
+help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
+ |
+LL ~ match *x {
+LL + _ => todo!(),
+LL ~ }
+ |
+
+error[E0004]: non-exhaustive patterns: `Ok(_)` and `Err(_)` not covered
+ --> $DIR/empty-types.rs:316:11
+ |
+LL | match *x {}
+ | ^^ patterns `Ok(_)` and `Err(_)` not covered
+ |
+note: `Result<!, !>` defined here
+ --> $SRC_DIR/core/src/result.rs:LL:COL
+ ::: $SRC_DIR/core/src/result.rs:LL:COL
+ |
+ = note: not covered
+ ::: $SRC_DIR/core/src/result.rs:LL:COL
+ |
+ = note: not covered
+ = note: the matched value is of type `Result<!, !>`
+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
+ |
+LL ~ match *x {
+LL + Ok(_) | Err(_) => todo!(),
+LL ~ }
+ |
+
+error[E0004]: non-exhaustive patterns: type `[!; 3]` is non-empty
+ --> $DIR/empty-types.rs:318:11
+ |
+LL | match *x {}
+ | ^^
+ |
+ = note: the matched value is of type `[!; 3]`
+help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
+ |
+LL ~ match *x {
+LL + _ => todo!(),
+LL ~ }
+ |
+
+error[E0004]: non-exhaustive patterns: type `&[!]` is non-empty
+ --> $DIR/empty-types.rs:323:11
+ |
+LL | match slice_never {}
+ | ^^^^^^^^^^^
+ |
+ = note: the matched value is of type `&[!]`
+help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
+ |
+LL ~ match slice_never {
+LL + _ => todo!(),
+LL + }
+ |
+
+error[E0004]: non-exhaustive patterns: `&[_, ..]` not covered
+ --> $DIR/empty-types.rs:325:11
+ |
+LL | match slice_never {
+ | ^^^^^^^^^^^ pattern `&[_, ..]` not covered
+ |
+ = note: the matched value is of type `&[!]`
+help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
+ |
+LL ~ [] => {},
+LL + &[_, ..] => todo!()
+ |
+
+error[E0004]: non-exhaustive patterns: `&[]`, `&[_]` and `&[_, _]` not covered
+ --> $DIR/empty-types.rs:334:11
+ |
+LL | match slice_never {
+ | ^^^^^^^^^^^ patterns `&[]`, `&[_]` and `&[_, _]` not covered
+ |
+ = note: the matched value is of type `&[!]`
+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
+ |
+LL ~ [_, _, _, ..] => {},
+LL + &[] | &[_] | &[_, _] => todo!()
+ |
+
+error[E0004]: non-exhaustive patterns: `&[]` and `&[_, ..]` not covered
+ --> $DIR/empty-types.rs:347:11
+ |
+LL | match slice_never {
+ | ^^^^^^^^^^^ patterns `&[]` and `&[_, ..]` not covered
+ |
+ = note: the matched value is of type `&[!]`
+ = note: match arms with guards don't count towards exhaustivity
+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
+ |
+LL ~ &[..] if false => {},
+LL + &[] | &[_, ..] => todo!()
+ |
+
+error[E0004]: non-exhaustive patterns: type `[!]` is non-empty
+ --> $DIR/empty-types.rs:353:11
+ |
+LL | match *slice_never {}
+ | ^^^^^^^^^^^^
+ |
+ = note: the matched value is of type `[!]`
+help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
+ |
+LL ~ match *slice_never {
+LL + _ => todo!(),
+LL + }
+ |
+
+error[E0004]: non-exhaustive patterns: type `[!; 3]` is non-empty
+ --> $DIR/empty-types.rs:360:11
+ |
+LL | match array_3_never {}
+ | ^^^^^^^^^^^^^
+ |
+ = note: the matched value is of type `[!; 3]`
+help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
+ |
+LL ~ match array_3_never {
+LL + _ => todo!(),
+LL + }
+ |
+
+error[E0004]: non-exhaustive patterns: type `[!; 0]` is non-empty
+ --> $DIR/empty-types.rs:383:11
+ |
+LL | match array_0_never {}
+ | ^^^^^^^^^^^^^
+ |
+ = note: the matched value is of type `[!; 0]`
+help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
+ |
+LL ~ match array_0_never {
+LL + _ => todo!(),
+LL + }
+ |
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:390:9
+ |
+LL | _ => {}
+ | ^
+
+error[E0004]: non-exhaustive patterns: `[]` not covered
+ --> $DIR/empty-types.rs:392:11
+ |
+LL | match array_0_never {
+ | ^^^^^^^^^^^^^ pattern `[]` not covered
+ |
+ = note: the matched value is of type `[!; 0]`
+ = note: match arms with guards don't count towards exhaustivity
+help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
+ |
+LL ~ [..] if false => {},
+LL + [] => todo!()
+ |
+
+error[E0004]: non-exhaustive patterns: `&Some(_)` not covered
+ --> $DIR/empty-types.rs:446:11
+ |
+LL | match ref_opt_never {
+ | ^^^^^^^^^^^^^ pattern `&Some(_)` not covered
+ |
+note: `Option<!>` defined here
+ --> $SRC_DIR/core/src/option.rs:LL:COL
+ ::: $SRC_DIR/core/src/option.rs:LL:COL
+ |
+ = note: not covered
+ = note: the matched value is of type `&Option<!>`
+help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
+ |
+LL ~ &None => {},
+LL + &Some(_) => todo!()
+ |
+
+error[E0004]: non-exhaustive patterns: `Some(_)` not covered
+ --> $DIR/empty-types.rs:487:11
+ |
+LL | match *ref_opt_never {
+ | ^^^^^^^^^^^^^^ pattern `Some(_)` not covered
+ |
+note: `Option<!>` defined here
+ --> $SRC_DIR/core/src/option.rs:LL:COL
+ ::: $SRC_DIR/core/src/option.rs:LL:COL
+ |
+ = note: not covered
+ = note: the matched value is of type `Option<!>`
+help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
+ |
+LL ~ None => {},
+LL + Some(_) => todo!()
+ |
+
+error[E0004]: non-exhaustive patterns: `Err(_)` not covered
+ --> $DIR/empty-types.rs:535:11
+ |
+LL | match *ref_res_never {
+ | ^^^^^^^^^^^^^^ pattern `Err(_)` not covered
+ |
+note: `Result<!, !>` defined here
+ --> $SRC_DIR/core/src/result.rs:LL:COL
+ ::: $SRC_DIR/core/src/result.rs:LL:COL
+ |
+ = note: not covered
+ = note: the matched value is of type `Result<!, !>`
+help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
+ |
+LL ~ Ok(_) => {},
+LL + Err(_) => todo!()
+ |
+
+error[E0004]: non-exhaustive patterns: `Err(_)` not covered
+ --> $DIR/empty-types.rs:546:11
+ |
+LL | match *ref_res_never {
+ | ^^^^^^^^^^^^^^ pattern `Err(_)` not covered
+ |
+note: `Result<!, !>` defined here
+ --> $SRC_DIR/core/src/result.rs:LL:COL
+ ::: $SRC_DIR/core/src/result.rs:LL:COL
+ |
+ = note: not covered
+ = note: the matched value is of type `Result<!, !>`
+help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
+ |
+LL ~ Ok(_a) => {},
+LL + Err(_) => todo!()
+ |
+
+error[E0004]: non-exhaustive patterns: type `(u32, !)` is non-empty
+ --> $DIR/empty-types.rs:565:11
+ |
+LL | match *ref_tuple_half_never {}
+ | ^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: the matched value is of type `(u32, !)`
+help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
+ |
+LL ~ match *ref_tuple_half_never {
+LL + _ => todo!(),
+LL + }
+ |
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:598:9
+ |
+LL | _ => {}
+ | ^
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:601:9
+ |
+LL | _x => {}
+ | ^^
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:604:9
+ |
+LL | _ if false => {}
+ | ^
+
+error: unreachable pattern
+ --> $DIR/empty-types.rs:607:9
+ |
+LL | _x if false => {}
+ | ^^
+
+error[E0004]: non-exhaustive patterns: `&_` not covered
+ --> $DIR/empty-types.rs:631:11
+ |
+LL | match ref_never {
+ | ^^^^^^^^^ pattern `&_` not covered
+ |
+ = note: the matched value is of type `&!`
+ = note: references are always considered inhabited
+ = note: match arms with guards don't count towards exhaustivity
+help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
+ |
+LL ~ &_a if false => {},
+LL + &_ => todo!()
+ |
+
+error[E0004]: non-exhaustive patterns: `Some(_)` not covered
+ --> $DIR/empty-types.rs:659:11
+ |
+LL | match *x {
+ | ^^ pattern `Some(_)` not covered
+ |
+note: `Option<Result<!, !>>` defined here
+ --> $SRC_DIR/core/src/option.rs:LL:COL
+ ::: $SRC_DIR/core/src/option.rs:LL:COL
+ |
+ = note: not covered
+ = note: the matched value is of type `Option<Result<!, !>>`
+help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
+ |
+LL ~ None => {},
+LL + Some(_) => todo!()
+ |
+
+error: aborting due to 48 previous errors
+
+Some errors have detailed explanations: E0004, E0005.
+For more information about an error, try `rustc --explain E0004`.
diff --git a/tests/ui/pattern/usefulness/empty-types.rs b/tests/ui/pattern/usefulness/empty-types.rs
new file mode 100644
index 000000000..1e1d23e44
--- /dev/null
+++ b/tests/ui/pattern/usefulness/empty-types.rs
@@ -0,0 +1,665 @@
+// revisions: normal exhaustive_patterns
+//
+// This tests correct handling of empty types in exhaustiveness checking.
+//
+// Most of the subtlety of this file happens in scrutinee places which are not required to hold
+// valid data, namely dereferences and union field accesses. In these cases, empty arms can
+// generally not be omitted, except with `exhaustive_patterns` which ignores this..
+#![feature(never_type)]
+// This feature is useful to avoid `!` falling back to `()` all the time.
+#![feature(never_type_fallback)]
+#![cfg_attr(exhaustive_patterns, feature(exhaustive_patterns))]
+#![allow(dead_code, unreachable_code)]
+#![deny(unreachable_patterns)]
+
+#[derive(Copy, Clone)]
+enum Void {}
+
+/// A bunch of never situations that can't be normally constructed.
+#[derive(Copy, Clone)]
+struct NeverBundle {
+ never: !,
+ void: Void,
+ tuple_never: (!, !),
+ tuple_half_never: (u32, !),
+ array_3_never: [!; 3],
+ result_never: Result<!, !>,
+}
+
+/// A simplified `MaybeUninit` to test union field accesses.
+#[derive(Copy, Clone)]
+union Uninit<T: Copy> {
+ value: T,
+ uninit: (),
+}
+
+impl<T: Copy> Uninit<T> {
+ fn new() -> Self {
+ Self { uninit: () }
+ }
+}
+
+// Simple cases of omitting empty arms, all with known_valid scrutinees.
+fn basic(x: NeverBundle) {
+ let never: ! = x.never;
+ match never {}
+ match never {
+ _ => {} //~ ERROR unreachable pattern
+ }
+ match never {
+ _x => {} //~ ERROR unreachable pattern
+ }
+
+ let ref_never: &! = &x.never;
+ match ref_never {}
+ //~^ ERROR non-empty
+ match ref_never {
+ // useful, reachable
+ _ => {}
+ }
+ match ref_never {
+ // useful, reachable
+ &_ => {}
+ }
+
+ let tuple_half_never: (u32, !) = x.tuple_half_never;
+ match tuple_half_never {}
+ //[normal]~^ ERROR non-empty
+ match tuple_half_never {
+ (_, _) => {} //[exhaustive_patterns]~ ERROR unreachable pattern
+ }
+
+ let tuple_never: (!, !) = x.tuple_never;
+ match tuple_never {}
+ //[normal]~^ ERROR non-empty
+ match tuple_never {
+ _ => {} //[exhaustive_patterns]~ ERROR unreachable pattern
+ }
+ match tuple_never {
+ (_, _) => {} //[exhaustive_patterns]~ ERROR unreachable pattern
+ }
+ match tuple_never.0 {}
+ match tuple_never.0 {
+ _ => {} //~ ERROR unreachable pattern
+ }
+
+ let res_u32_never: Result<u32, !> = Ok(0);
+ match res_u32_never {}
+ //~^ ERROR non-exhaustive
+ match res_u32_never {
+ //[normal]~^ ERROR non-exhaustive
+ Ok(_) => {}
+ }
+ match res_u32_never {
+ Ok(_) => {}
+ Err(_) => {} //[exhaustive_patterns]~ ERROR unreachable pattern
+ }
+ match res_u32_never {
+ //~^ ERROR non-exhaustive
+ Ok(0) => {}
+ Err(_) => {} //[exhaustive_patterns]~ ERROR unreachable pattern
+ }
+ let Ok(_x) = res_u32_never;
+ //[normal]~^ ERROR refutable
+ let Ok(_x) = res_u32_never.as_ref();
+ //~^ ERROR refutable
+ // Non-obvious difference: here there's an implicit dereference in the patterns, which makes the
+ // inner place !known_valid. `exhaustive_patterns` ignores this.
+ let Ok(_x) = &res_u32_never;
+ //[normal]~^ ERROR refutable
+
+ let result_never: Result<!, !> = x.result_never;
+ match result_never {}
+ //[normal]~^ ERROR non-exhaustive
+ match result_never {
+ _ => {} //[exhaustive_patterns]~ ERROR unreachable pattern
+ }
+ match result_never {
+ //[normal]~^ ERROR non-exhaustive
+ Ok(_) => {} //[exhaustive_patterns]~ ERROR unreachable pattern
+ }
+ match result_never {
+ Ok(_) => {} //[exhaustive_patterns]~ ERROR unreachable pattern
+ _ => {} //[exhaustive_patterns]~ ERROR unreachable pattern
+ }
+ match result_never {
+ Ok(_) => {} //[exhaustive_patterns]~ ERROR unreachable pattern
+ Err(_) => {} //[exhaustive_patterns]~ ERROR unreachable pattern
+ }
+}
+
+// Check for a few cases that `Void` and `!` are treated the same.
+fn void_same_as_never(x: NeverBundle) {
+ unsafe {
+ match x.void {}
+ match x.void {
+ _ => {} //~ ERROR unreachable pattern
+ }
+ match x.void {
+ _ if false => {} //~ ERROR unreachable pattern
+ }
+ let opt_void: Option<Void> = None;
+ match opt_void {
+ //[normal]~^ ERROR non-exhaustive
+ None => {}
+ }
+ match opt_void {
+ None => {}
+ Some(_) => {} //[exhaustive_patterns]~ ERROR unreachable pattern
+ }
+ match opt_void {
+ None => {}
+ _ => {} //[exhaustive_patterns]~ ERROR unreachable pattern
+ }
+
+ let ref_void: &Void = &x.void;
+ match *ref_void {}
+ match *ref_void {
+ _ => {}
+ }
+ let ref_opt_void: &Option<Void> = &None;
+ match *ref_opt_void {
+ //[normal]~^ ERROR non-exhaustive
+ None => {}
+ }
+ match *ref_opt_void {
+ None => {}
+ Some(_) => {}
+ }
+ match *ref_opt_void {
+ None => {}
+ _ => {}
+ }
+ match *ref_opt_void {
+ None => {}
+ _a => {}
+ }
+ let union_void = Uninit::<Void>::new();
+ match union_void.value {}
+ match union_void.value {
+ _ => {}
+ }
+ let ptr_void: *const Void = std::ptr::null();
+ match *ptr_void {}
+ match *ptr_void {
+ _ => {}
+ }
+ }
+}
+
+// Test if we correctly determine validity from the scrutinee expression.
+fn invalid_scrutinees(x: NeverBundle) {
+ let ptr_never: *const ! = std::ptr::null();
+ let never: ! = x.never;
+ let ref_never: &! = &never;
+
+ struct NestedNeverBundle(NeverBundle);
+ let nested_x = NestedNeverBundle(x);
+
+ // These should be considered known_valid and warn unreachable.
+ unsafe {
+ // A plain `!` value must be valid.
+ match never {}
+ match never {
+ _ => {} //~ ERROR unreachable pattern
+ }
+ // A block forces a copy.
+ match { *ptr_never } {}
+ match { *ptr_never } {
+ _ => {} //~ ERROR unreachable pattern
+ }
+ // This field access is not a dereference.
+ match x.never {}
+ match x.never {
+ _ => {} //~ ERROR unreachable pattern
+ }
+ // This nested field access is not a dereference.
+ match nested_x.0.never {}
+ match nested_x.0.never {
+ _ => {} //~ ERROR unreachable pattern
+ }
+ // Indexing is like a field access. This one does not access behind a reference.
+ let array_3_never: [!; 3] = x.array_3_never;
+ match array_3_never[0] {}
+ match array_3_never[0] {
+ _ => {} //~ ERROR unreachable pattern
+ }
+ }
+
+ // These should be considered !known_valid and not warn unreachable.
+ unsafe {
+ // A pointer may point to a place with an invalid value.
+ match *ptr_never {}
+ match *ptr_never {
+ _ => {}
+ }
+ // A reference may point to a place with an invalid value.
+ match *ref_never {}
+ match *ref_never {
+ _ => {}
+ }
+ // This field access is a dereference.
+ let ref_x: &NeverBundle = &x;
+ match ref_x.never {}
+ match ref_x.never {
+ _ => {}
+ }
+ // This nested field access is a dereference.
+ let nested_ref_x: &NestedNeverBundle = &nested_x;
+ match nested_ref_x.0.never {}
+ match nested_ref_x.0.never {
+ _ => {}
+ }
+ // A cast does not load.
+ match (*ptr_never as Void) {}
+ match (*ptr_never as Void) {
+ _ => {}
+ }
+ // A union field may contain invalid data.
+ let union_never = Uninit::<!>::new();
+ match union_never.value {}
+ match union_never.value {
+ _ => {}
+ }
+ // Indexing is like a field access. This one accesses behind a reference.
+ let slice_never: &[!] = &[];
+ match slice_never[0] {}
+ match slice_never[0] {
+ _ => {}
+ }
+ }
+}
+
+// Test we correctly track validity as we dig into patterns. Validity changes when we go under a
+// dereference or a union field access, and it otherwise preserved.
+fn nested_validity_tracking(bundle: NeverBundle) {
+ let never: ! = bundle.never;
+ let ref_never: &! = &never;
+ let tuple_never: (!, !) = bundle.tuple_never;
+ let result_never: Result<!, !> = bundle.result_never;
+ let union_never = Uninit::<!>::new();
+
+ // These should be considered known_valid and warn unreachable.
+ match never {
+ _ => {} //~ ERROR unreachable pattern
+ }
+ match tuple_never {
+ (_, _) => {} //[exhaustive_patterns]~ ERROR unreachable pattern
+ }
+ match result_never {
+ Ok(_) => {} //[exhaustive_patterns]~ ERROR unreachable pattern
+ Err(_) => {} //[exhaustive_patterns]~ ERROR unreachable pattern
+ }
+
+ // These should be considered !known_valid and not warn unreachable.
+ match ref_never {
+ &_ => {}
+ }
+ match union_never {
+ Uninit { value: _ } => {}
+ }
+}
+
+// Test we don't allow empty matches on empty types if the scrutinee is `!known_valid`.
+fn invalid_empty_match(bundle: NeverBundle) {
+ // We allow these two for backwards-compability.
+ let x: &! = &bundle.never;
+ match *x {}
+ let x: &Void = &bundle.void;
+ match *x {}
+
+ let x: &(u32, !) = &bundle.tuple_half_never;
+ match *x {} //[normal]~ ERROR non-exhaustive
+ let x: &(!, !) = &bundle.tuple_never;
+ match *x {} //[normal]~ ERROR non-exhaustive
+ let x: &Result<!, !> = &bundle.result_never;
+ match *x {} //[normal]~ ERROR non-exhaustive
+ let x: &[!; 3] = &bundle.array_3_never;
+ match *x {} //[normal]~ ERROR non-exhaustive
+}
+
+fn arrays_and_slices(x: NeverBundle) {
+ let slice_never: &[!] = &[];
+ match slice_never {}
+ //~^ ERROR non-empty
+ match slice_never {
+ //[normal]~^ ERROR not covered
+ [] => {}
+ }
+ match slice_never {
+ [] => {}
+ [_] => {}
+ [_, _, ..] => {}
+ }
+ match slice_never {
+ //[normal]~^ ERROR `&[]`, `&[_]` and `&[_, _]` not covered
+ //[exhaustive_patterns]~^^ ERROR `&[]` not covered
+ [_, _, _, ..] => {}
+ }
+ match slice_never {
+ [] => {}
+ _ => {}
+ }
+ match slice_never {
+ [] => {}
+ _x => {}
+ }
+ match slice_never {
+ //[normal]~^ ERROR `&[]` and `&[_, ..]` not covered
+ //[exhaustive_patterns]~^^ ERROR `&[]` not covered
+ &[..] if false => {}
+ }
+
+ match *slice_never {}
+ //~^ ERROR non-empty
+ match *slice_never {
+ _ => {}
+ }
+
+ let array_3_never: [!; 3] = x.array_3_never;
+ match array_3_never {}
+ //[normal]~^ ERROR non-empty
+ match array_3_never {
+ _ => {} //[exhaustive_patterns]~ ERROR unreachable pattern
+ }
+ match array_3_never {
+ [_, _, _] => {} //[exhaustive_patterns]~ ERROR unreachable pattern
+ }
+ match array_3_never {
+ [_, ..] => {} //[exhaustive_patterns]~ ERROR unreachable pattern
+ }
+
+ let ref_array_3_never: &[!; 3] = &array_3_never;
+ match ref_array_3_never {
+ // useful, reachable
+ &[_, _, _] => {}
+ }
+ match ref_array_3_never {
+ // useful, !reachable
+ &[_x, _, _] => {}
+ }
+
+ let array_0_never: [!; 0] = [];
+ match array_0_never {}
+ //~^ ERROR non-empty
+ match array_0_never {
+ [] => {}
+ }
+ match array_0_never {
+ [] => {}
+ _ => {} //~ ERROR unreachable pattern
+ }
+ match array_0_never {
+ //~^ ERROR `[]` not covered
+ [..] if false => {}
+ }
+}
+
+// The difference between `_` and `_a` patterns is that `_a` loads the value. In case of an empty
+// type, this asserts validity of the value, and thus the binding is unreachable. We don't yet
+// distinguish these cases since we don't lint "unreachable" on `useful && !reachable` arms.
+// Once/if never patterns are a thing, we can warn that the `_a` cases should be never patterns.
+fn bindings(x: NeverBundle) {
+ let opt_never: Option<!> = None;
+ let ref_never: &! = &x.never;
+ let ref_opt_never: &Option<!> = &None;
+
+ // On a known_valid place.
+ match opt_never {
+ None => {}
+ // !useful, !reachable
+ Some(_) => {} //[exhaustive_patterns]~ ERROR unreachable pattern
+ }
+ match opt_never {
+ None => {}
+ // !useful, !reachable
+ Some(_a) => {} //[exhaustive_patterns]~ ERROR unreachable pattern
+ }
+ match opt_never {
+ None => {}
+ // !useful, !reachable
+ _ => {} //[exhaustive_patterns]~ ERROR unreachable pattern
+ }
+ match opt_never {
+ None => {}
+ // !useful, !reachable
+ _a => {} //[exhaustive_patterns]~ ERROR unreachable pattern
+ }
+
+ // The scrutinee is known_valid, but under the `&` isn't anymore.
+ match ref_never {
+ // useful, reachable
+ _ => {}
+ }
+ match ref_never {
+ // useful, reachable
+ &_ => {}
+ }
+ match ref_never {
+ // useful, reachable
+ _a => {}
+ }
+ match ref_never {
+ // useful, !reachable
+ &_a => {}
+ }
+ match ref_opt_never {
+ //[normal]~^ ERROR non-exhaustive
+ &None => {}
+ }
+ match ref_opt_never {
+ &None => {}
+ // useful, reachable
+ _ => {}
+ }
+ match ref_opt_never {
+ &None => {}
+ // useful, reachable
+ _a => {}
+ }
+ match ref_opt_never {
+ &None => {}
+ // useful, reachable
+ &_ => {}
+ }
+ match ref_opt_never {
+ &None => {}
+ // useful, !reachable
+ &_a => {}
+ }
+
+ // On a !known_valid place.
+ match *ref_never {}
+ match *ref_never {
+ // useful, reachable
+ _ => {}
+ }
+ match *ref_never {
+ // useful, !reachable
+ _a => {}
+ }
+ // This is equivalent to `match ref_never { _a => {} }`. In other words, it asserts validity of
+ // `ref_never` but says nothing of the data at `*ref_never`.
+ match *ref_never {
+ // useful, reachable
+ ref _a => {}
+ }
+ match *ref_opt_never {
+ //[normal]~^ ERROR non-exhaustive
+ None => {}
+ }
+ match *ref_opt_never {
+ None => {}
+ // useful, reachable
+ Some(_) => {}
+ }
+ match *ref_opt_never {
+ None => {}
+ // useful, !reachable
+ Some(_a) => {}
+ }
+ match *ref_opt_never {
+ None => {}
+ // useful, reachable
+ _ => {}
+ }
+ match *ref_opt_never {
+ None => {}
+ // useful, !reachable
+ _a => {}
+ }
+ match *ref_opt_never {
+ None => {}
+ // useful, !reachable
+ _a @ Some(_) => {}
+ }
+ // This is equivalent to `match ref_opt_never { None => {}, _a => {} }`. In other words, it
+ // asserts validity of `ref_opt_never` but says nothing of the data at `*ref_opt_never`.
+ match *ref_opt_never {
+ None => {}
+ // useful, reachable
+ ref _a => {}
+ }
+ match *ref_opt_never {
+ None => {}
+ // useful, reachable
+ ref _a @ Some(_) => {}
+ }
+ match *ref_opt_never {
+ None => {}
+ // useful, !reachable
+ ref _a @ Some(_b) => {}
+ }
+
+ let ref_res_never: &Result<!, !> = &x.result_never;
+ match *ref_res_never {
+ //[normal]~^ ERROR non-exhaustive
+ // useful, reachable
+ Ok(_) => {}
+ }
+ match *ref_res_never {
+ // useful, reachable
+ Ok(_) => {}
+ // useful, reachable
+ _ => {}
+ }
+ match *ref_res_never {
+ //[normal]~^ ERROR non-exhaustive
+ // useful, !reachable
+ Ok(_a) => {}
+ }
+ match *ref_res_never {
+ // useful, !reachable
+ Ok(_a) => {}
+ // useful, reachable
+ _ => {}
+ }
+ match *ref_res_never {
+ // useful, !reachable
+ Ok(_a) => {}
+ // useful, reachable
+ Err(_) => {}
+ }
+
+ let ref_tuple_half_never: &(u32, !) = &x.tuple_half_never;
+ match *ref_tuple_half_never {}
+ //[normal]~^ ERROR non-empty
+ match *ref_tuple_half_never {
+ // useful, reachable
+ (_, _) => {}
+ }
+ match *ref_tuple_half_never {
+ // useful, reachable
+ (_x, _) => {}
+ }
+ match *ref_tuple_half_never {
+ // useful, !reachable
+ (_, _x) => {}
+ }
+ match *ref_tuple_half_never {
+ // useful, !reachable
+ (0, _x) => {}
+ // useful, reachable
+ (1.., _) => {}
+ }
+}
+
+// When we execute the condition for a guard we loads from all bindings. This asserts validity at
+// all places with bindings. Surprisingly this can make subsequent arms unreachable. We choose to
+// not detect this in exhaustiveness because this is rather subtle. With never patterns, we would
+// recommend using a never pattern instead.
+fn guards_and_validity(x: NeverBundle) {
+ let never: ! = x.never;
+ let ref_never: &! = &never;
+
+ // Basic guard behavior when known_valid.
+ match never {}
+ match never {
+ _ => {} //~ ERROR unreachable pattern
+ }
+ match never {
+ _x => {} //~ ERROR unreachable pattern
+ }
+ match never {
+ _ if false => {} //~ ERROR unreachable pattern
+ }
+ match never {
+ _x if false => {} //~ ERROR unreachable pattern
+ }
+
+ // If the pattern under the guard doesn't load, all is normal.
+ match *ref_never {
+ // useful, reachable
+ _ if false => {}
+ // useful, reachable
+ _ => {}
+ }
+ // Now the madness commences. The guard caused a load of the value thus asserting validity. So
+ // there's no invalid value for `_` to catch. So the second pattern is unreachable despite the
+ // guard not being taken.
+ match *ref_never {
+ // useful, !reachable
+ _a if false => {}
+ // !useful, !reachable
+ _ => {}
+ }
+ // The above still applies to the implicit `_` pattern used for exhaustiveness.
+ match *ref_never {
+ // useful, !reachable
+ _a if false => {}
+ }
+ match ref_never {
+ //[normal]~^ ERROR non-exhaustive
+ // useful, !reachable
+ &_a if false => {}
+ }
+
+ // Same but with subpatterns.
+ let ref_result_never: &Result<!, !> = &x.result_never;
+ match *ref_result_never {
+ // useful, !reachable
+ Ok(_x) if false => {}
+ // !useful, !reachable
+ Ok(_) => {}
+ // useful, !reachable
+ Err(_) => {}
+ }
+ let ref_tuple_never: &(!, !) = &x.tuple_never;
+ match *ref_tuple_never {
+ // useful, !reachable
+ (_, _x) if false => {}
+ // !useful, !reachable
+ (_, _) => {}
+ }
+}
+
+fn diagnostics_subtlety(x: NeverBundle) {
+ // Regression test for diagnostics: don't report `Some(Ok(_))` and `Some(Err(_))`.
+ let x: &Option<Result<!, !>> = &None;
+ match *x {
+ //[normal]~^ ERROR `Some(_)` not covered
+ None => {}
+ }
+}
+
+fn main() {}
diff --git a/tests/ui/pattern/usefulness/guards.stderr b/tests/ui/pattern/usefulness/guards.stderr
index fc6748958..ad9046fe2 100644
--- a/tests/ui/pattern/usefulness/guards.stderr
+++ b/tests/ui/pattern/usefulness/guards.stderr
@@ -11,6 +11,6 @@ LL ~ 128 ..= 255 if true => {},
LL + 128_u8..=u8::MAX => todo!()
|
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0004`.
diff --git a/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.allow.stderr b/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.allow.stderr
deleted file mode 100644
index 7f26c93aa..000000000
--- a/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.allow.stderr
+++ /dev/null
@@ -1,17 +0,0 @@
-error[E0004]: non-exhaustive patterns: type `usize` is non-empty
- --> $DIR/pointer-sized-int.rs:54:11
- |
-LL | match 7usize {}
- | ^^^^^^
- |
- = note: the matched value is of type `usize`
-help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
- |
-LL ~ match 7usize {
-LL + _ => todo!(),
-LL + }
- |
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0004`.
diff --git a/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.deny.stderr b/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.deny.stderr
index d16ec5412..416523213 100644
--- a/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.deny.stderr
+++ b/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.deny.stderr
@@ -1,162 +1,150 @@
error[E0004]: non-exhaustive patterns: `usize::MAX..` not covered
- --> $DIR/pointer-sized-int.rs:14:11
+ --> $DIR/pointer-sized-int.rs:13:11
|
LL | match 0usize {
| ^^^^^^ pattern `usize::MAX..` not covered
|
= note: the matched value is of type `usize`
= note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively
- = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
-LL ~ 0 ..= usize::MAX => {},
+LL ~ 0..=usize::MAX => {},
LL + usize::MAX.. => todo!()
|
error[E0004]: non-exhaustive patterns: `..isize::MIN` and `isize::MAX..` not covered
- --> $DIR/pointer-sized-int.rs:19:11
+ --> $DIR/pointer-sized-int.rs:18:11
|
LL | match 0isize {
| ^^^^^^ patterns `..isize::MIN` and `isize::MAX..` not covered
|
= note: the matched value is of type `isize`
= note: `isize` does not have fixed minimum and maximum values, so half-open ranges are necessary to match exhaustively
- = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching
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
|
-LL ~ isize::MIN ..= isize::MAX => {},
+LL ~ isize::MIN..=isize::MAX => {},
LL + ..isize::MIN | isize::MAX.. => todo!()
|
error[E0004]: non-exhaustive patterns: `usize::MAX..` not covered
- --> $DIR/pointer-sized-int.rs:25:8
+ --> $DIR/pointer-sized-int.rs:23:8
|
LL | m!(0usize, 0..=usize::MAX);
| ^^^^^^ pattern `usize::MAX..` not covered
|
= note: the matched value is of type `usize`
= note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively
- = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL | match $s { $($t)+ => {}, usize::MAX.. => todo!() }
| +++++++++++++++++++++++++
error[E0004]: non-exhaustive patterns: `usize::MAX..` not covered
- --> $DIR/pointer-sized-int.rs:27:8
+ --> $DIR/pointer-sized-int.rs:25:8
|
LL | m!(0usize, 0..5 | 5..=usize::MAX);
| ^^^^^^ pattern `usize::MAX..` not covered
|
= note: the matched value is of type `usize`
= note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively
- = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL | match $s { $($t)+ => {}, usize::MAX.. => todo!() }
| +++++++++++++++++++++++++
error[E0004]: non-exhaustive patterns: `usize::MAX..` not covered
- --> $DIR/pointer-sized-int.rs:29:8
+ --> $DIR/pointer-sized-int.rs:27:8
|
LL | m!(0usize, 0..usize::MAX | usize::MAX);
| ^^^^^^ pattern `usize::MAX..` not covered
|
= note: the matched value is of type `usize`
= note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively
- = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL | match $s { $($t)+ => {}, usize::MAX.. => todo!() }
| +++++++++++++++++++++++++
error[E0004]: non-exhaustive patterns: `(usize::MAX.., _)` not covered
- --> $DIR/pointer-sized-int.rs:31:8
+ --> $DIR/pointer-sized-int.rs:29:8
|
LL | m!((0usize, true), (0..5, true) | (5..=usize::MAX, true) | (0..=usize::MAX, false));
| ^^^^^^^^^^^^^^ pattern `(usize::MAX.., _)` not covered
|
= note: the matched value is of type `(usize, bool)`
= note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively
- = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL | match $s { $($t)+ => {}, (usize::MAX.., _) => todo!() }
| ++++++++++++++++++++++++++++++
error[E0004]: non-exhaustive patterns: `..isize::MIN` and `isize::MAX..` not covered
- --> $DIR/pointer-sized-int.rs:36:8
+ --> $DIR/pointer-sized-int.rs:38:8
|
LL | m!(0isize, isize::MIN..=isize::MAX);
| ^^^^^^ patterns `..isize::MIN` and `isize::MAX..` not covered
|
= note: the matched value is of type `isize`
= note: `isize` does not have fixed minimum and maximum values, so half-open ranges are necessary to match exhaustively
- = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching
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
|
LL | match $s { $($t)+ => {}, ..isize::MIN | isize::MAX.. => todo!() }
| ++++++++++++++++++++++++++++++++++++++++
error[E0004]: non-exhaustive patterns: `..isize::MIN` and `isize::MAX..` not covered
- --> $DIR/pointer-sized-int.rs:38:8
+ --> $DIR/pointer-sized-int.rs:40:8
|
LL | m!(0isize, isize::MIN..5 | 5..=isize::MAX);
| ^^^^^^ patterns `..isize::MIN` and `isize::MAX..` not covered
|
= note: the matched value is of type `isize`
= note: `isize` does not have fixed minimum and maximum values, so half-open ranges are necessary to match exhaustively
- = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching
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
|
LL | match $s { $($t)+ => {}, ..isize::MIN | isize::MAX.. => todo!() }
| ++++++++++++++++++++++++++++++++++++++++
error[E0004]: non-exhaustive patterns: `..isize::MIN` and `isize::MAX..` not covered
- --> $DIR/pointer-sized-int.rs:40:8
+ --> $DIR/pointer-sized-int.rs:42:8
|
-LL | m!(0isize, isize::MIN..isize::MAX | isize::MAX);
+LL | m!(0isize, isize::MIN..=-1 | 0 | 1..=isize::MAX);
| ^^^^^^ patterns `..isize::MIN` and `isize::MAX..` not covered
|
= note: the matched value is of type `isize`
= note: `isize` does not have fixed minimum and maximum values, so half-open ranges are necessary to match exhaustively
- = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching
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
|
LL | match $s { $($t)+ => {}, ..isize::MIN | isize::MAX.. => todo!() }
| ++++++++++++++++++++++++++++++++++++++++
-error[E0004]: non-exhaustive patterns: `(..isize::MIN, _)` and `(isize::MAX.., _)` not covered
- --> $DIR/pointer-sized-int.rs:42:8
+error[E0004]: non-exhaustive patterns: `..isize::MIN` and `isize::MAX..` not covered
+ --> $DIR/pointer-sized-int.rs:44:8
|
-LL | m!((0isize, true), (isize::MIN..5, true)
- | ^^^^^^^^^^^^^^ patterns `(..isize::MIN, _)` and `(isize::MAX.., _)` not covered
+LL | m!(0isize, isize::MIN..isize::MAX | isize::MAX);
+ | ^^^^^^ patterns `..isize::MIN` and `isize::MAX..` not covered
|
- = note: the matched value is of type `(isize, bool)`
+ = note: the matched value is of type `isize`
= note: `isize` does not have fixed minimum and maximum values, so half-open ranges are necessary to match exhaustively
- = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching
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
|
-LL | match $s { $($t)+ => {}, (..isize::MIN, _) | (isize::MAX.., _) => todo!() }
- | ++++++++++++++++++++++++++++++++++++++++++++++++++
+LL | match $s { $($t)+ => {}, ..isize::MIN | isize::MAX.. => todo!() }
+ | ++++++++++++++++++++++++++++++++++++++++
-error[E0004]: non-exhaustive patterns: `..isize::MIN` and `isize::MAX..` not covered
- --> $DIR/pointer-sized-int.rs:47:11
+error[E0004]: non-exhaustive patterns: `(..isize::MIN, _)` and `(isize::MAX.., _)` not covered
+ --> $DIR/pointer-sized-int.rs:47:9
|
-LL | match 0isize {
- | ^^^^^^ patterns `..isize::MIN` and `isize::MAX..` not covered
+LL | (0isize, true),
+ | ^^^^^^^^^^^^^^ patterns `(..isize::MIN, _)` and `(isize::MAX.., _)` not covered
|
- = note: the matched value is of type `isize`
+ = note: the matched value is of type `(isize, bool)`
= note: `isize` does not have fixed minimum and maximum values, so half-open ranges are necessary to match exhaustively
- = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching
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
|
-LL ~ 1 ..= isize::MAX => {},
-LL + ..isize::MIN | isize::MAX.. => todo!()
- |
+LL | match $s { $($t)+ => {}, (..isize::MIN, _) | (isize::MAX.., _) => todo!() }
+ | ++++++++++++++++++++++++++++++++++++++++++++++++++
error[E0004]: non-exhaustive patterns: type `usize` is non-empty
- --> $DIR/pointer-sized-int.rs:54:11
+ --> $DIR/pointer-sized-int.rs:58:11
|
LL | match 7usize {}
| ^^^^^^
diff --git a/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.rs b/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.rs
index 20a3cbe12..3778dede7 100644
--- a/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.rs
+++ b/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.rs
@@ -1,6 +1,5 @@
-// revisions: allow deny
+// revisions: deny
#![feature(exclusive_range_pattern)]
-#![cfg_attr(allow, feature(precise_pointer_size_matching))]
#![allow(overlapping_range_endpoints)]
macro_rules! m {
@@ -12,44 +11,49 @@ macro_rules! m {
#[rustfmt::skip]
fn main() {
match 0usize {
- //[deny]~^ ERROR non-exhaustive patterns
- 0 ..= usize::MAX => {}
+ //~^ ERROR non-exhaustive patterns
+ 0..=usize::MAX => {}
}
match 0isize {
- //[deny]~^ ERROR non-exhaustive patterns
- isize::MIN ..= isize::MAX => {}
+ //~^ ERROR non-exhaustive patterns
+ isize::MIN..=isize::MAX => {}
}
- m!(0usize, 0..);
m!(0usize, 0..=usize::MAX);
- //[deny]~^ ERROR non-exhaustive patterns
+ //~^ ERROR non-exhaustive patterns
m!(0usize, 0..5 | 5..=usize::MAX);
- //[deny]~^ ERROR non-exhaustive patterns
+ //~^ ERROR non-exhaustive patterns
m!(0usize, 0..usize::MAX | usize::MAX);
- //[deny]~^ ERROR non-exhaustive patterns
+ //~^ ERROR non-exhaustive patterns
m!((0usize, true), (0..5, true) | (5..=usize::MAX, true) | (0..=usize::MAX, false));
- //[deny]~^ ERROR non-exhaustive patterns
+ //~^ ERROR non-exhaustive patterns
+
+ m!(0usize, 0..);
+ m!(0usize, 0..5 | 5..);
+ m!(0usize, ..5 | 5..);
+ m!((0usize, true), (0..5, true) | (5.., true) | (0.., false));
m!(0usize, 0..=usize::MAX | usize::MAX..);
- m!(0isize, ..0 | 0..);
m!(0isize, isize::MIN..=isize::MAX);
- //[deny]~^ ERROR non-exhaustive patterns
+ //~^ ERROR non-exhaustive patterns
m!(0isize, isize::MIN..5 | 5..=isize::MAX);
- //[deny]~^ ERROR non-exhaustive patterns
+ //~^ ERROR non-exhaustive patterns
+ m!(0isize, isize::MIN..=-1 | 0 | 1..=isize::MAX);
+ //~^ ERROR non-exhaustive patterns
m!(0isize, isize::MIN..isize::MAX | isize::MAX);
- //[deny]~^ ERROR non-exhaustive patterns
- m!((0isize, true), (isize::MIN..5, true)
- | (5..=isize::MAX, true) | (isize::MIN..=isize::MAX, false));
- //[deny]~^^ ERROR non-exhaustive patterns
- m!(0isize, ..=isize::MIN | isize::MIN..=isize::MAX | isize::MAX..);
+ //~^ ERROR non-exhaustive patterns
+ m!(
+ (0isize, true),
+ (isize::MIN..5, true) | (5..=isize::MAX, true) | (isize::MIN..=isize::MAX, false)
+ );
+ //~^^^ ERROR non-exhaustive patterns
- match 0isize {
- //[deny]~^ ERROR non-exhaustive patterns
- isize::MIN ..= -1 => {}
- 0 => {}
- 1 ..= isize::MAX => {}
- }
+ m!(0isize, ..0 | 0..);
+ m!(0isize, ..5 | 5..);
+ m!((0isize, true), (..5, true)
+ | (5.., true) | (..0 | 0.., false));
+ m!(0isize, ..=isize::MIN | isize::MIN..=isize::MAX | isize::MAX..);
match 7usize {}
//~^ ERROR non-exhaustive patterns
diff --git a/tests/ui/pattern/usefulness/integer-ranges/precise_pointer_matching-message.stderr b/tests/ui/pattern/usefulness/integer-ranges/precise_pointer_matching-message.stderr
index a7f93648e..36743aa81 100644
--- a/tests/ui/pattern/usefulness/integer-ranges/precise_pointer_matching-message.stderr
+++ b/tests/ui/pattern/usefulness/integer-ranges/precise_pointer_matching-message.stderr
@@ -6,7 +6,6 @@ LL | match 0usize {
|
= note: the matched value is of type `usize`
= note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively
- = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ 0..=usize::MAX => {},
@@ -21,7 +20,6 @@ LL | match 0isize {
|
= note: the matched value is of type `isize`
= note: `isize` does not have fixed minimum and maximum values, so half-open ranges are necessary to match exhaustively
- = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching
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
|
LL ~ isize::MIN..=isize::MAX => {},
diff --git a/tests/ui/pattern/usefulness/integer-ranges/reachability.rs b/tests/ui/pattern/usefulness/integer-ranges/reachability.rs
index fb4d59b05..247fdd915 100644
--- a/tests/ui/pattern/usefulness/integer-ranges/reachability.rs
+++ b/tests/ui/pattern/usefulness/integer-ranges/reachability.rs
@@ -9,9 +9,10 @@ macro_rules! m {
$t2 => {}
_ => {}
}
- }
+ };
}
+#[rustfmt::skip]
fn main() {
m!(0u8, 42, 41);
m!(0u8, 42, 42); //~ ERROR unreachable pattern
@@ -85,7 +86,7 @@ fn main() {
match 'a' {
'\u{0}'..='\u{D7FF}' => {},
'\u{E000}'..='\u{10_FFFF}' => {},
- '\u{D7FF}'..='\u{E000}' => {}, // FIXME should be unreachable
+ '\u{D7FF}'..='\u{E000}' => {}, //~ ERROR unreachable pattern
}
match (0u8, true) {
diff --git a/tests/ui/pattern/usefulness/integer-ranges/reachability.stderr b/tests/ui/pattern/usefulness/integer-ranges/reachability.stderr
index 0ffb0ffd8..c5b028d20 100644
--- a/tests/ui/pattern/usefulness/integer-ranges/reachability.stderr
+++ b/tests/ui/pattern/usefulness/integer-ranges/reachability.stderr
@@ -1,5 +1,5 @@
error: unreachable pattern
- --> $DIR/reachability.rs:17:17
+ --> $DIR/reachability.rs:18:17
|
LL | m!(0u8, 42, 42);
| ^^
@@ -11,127 +11,127 @@ LL | #![deny(unreachable_patterns)]
| ^^^^^^^^^^^^^^^^^^^^
error: unreachable pattern
- --> $DIR/reachability.rs:21:22
+ --> $DIR/reachability.rs:22:22
|
LL | m!(0u8, 20..=30, 20);
| ^^
error: unreachable pattern
- --> $DIR/reachability.rs:22:22
+ --> $DIR/reachability.rs:23:22
|
LL | m!(0u8, 20..=30, 21);
| ^^
error: unreachable pattern
- --> $DIR/reachability.rs:23:22
+ --> $DIR/reachability.rs:24:22
|
LL | m!(0u8, 20..=30, 25);
| ^^
error: unreachable pattern
- --> $DIR/reachability.rs:24:22
+ --> $DIR/reachability.rs:25:22
|
LL | m!(0u8, 20..=30, 29);
| ^^
error: unreachable pattern
- --> $DIR/reachability.rs:25:22
+ --> $DIR/reachability.rs:26:22
|
LL | m!(0u8, 20..=30, 30);
| ^^
error: unreachable pattern
- --> $DIR/reachability.rs:28:21
+ --> $DIR/reachability.rs:29:21
|
LL | m!(0u8, 20..30, 20);
| ^^
error: unreachable pattern
- --> $DIR/reachability.rs:29:21
+ --> $DIR/reachability.rs:30:21
|
LL | m!(0u8, 20..30, 21);
| ^^
error: unreachable pattern
- --> $DIR/reachability.rs:30:21
+ --> $DIR/reachability.rs:31:21
|
LL | m!(0u8, 20..30, 25);
| ^^
error: unreachable pattern
- --> $DIR/reachability.rs:31:21
+ --> $DIR/reachability.rs:32:21
|
LL | m!(0u8, 20..30, 29);
| ^^
error: unreachable pattern
- --> $DIR/reachability.rs:35:22
+ --> $DIR/reachability.rs:36:22
|
LL | m!(0u8, 20..=30, 20..=30);
| ^^^^^^^
error: unreachable pattern
- --> $DIR/reachability.rs:36:22
+ --> $DIR/reachability.rs:37:22
|
LL | m!(0u8, 20.. 30, 20.. 30);
| ^^^^^^^
error: unreachable pattern
- --> $DIR/reachability.rs:37:22
+ --> $DIR/reachability.rs:38:22
|
LL | m!(0u8, 20..=30, 20.. 30);
| ^^^^^^^
error: unreachable pattern
- --> $DIR/reachability.rs:39:22
+ --> $DIR/reachability.rs:40:22
|
LL | m!(0u8, 20..=30, 21..=30);
| ^^^^^^^
error: unreachable pattern
- --> $DIR/reachability.rs:40:22
+ --> $DIR/reachability.rs:41:22
|
LL | m!(0u8, 20..=30, 20..=29);
| ^^^^^^^
error: unreachable pattern
- --> $DIR/reachability.rs:42:24
+ --> $DIR/reachability.rs:43:24
|
LL | m!('a', 'A'..='z', 'a'..='z');
| ^^^^^^^^^
error: unreachable pattern
- --> $DIR/reachability.rs:49:9
+ --> $DIR/reachability.rs:50:9
|
LL | 5..=8 => {},
| ^^^^^
error: unreachable pattern
- --> $DIR/reachability.rs:55:9
+ --> $DIR/reachability.rs:56:9
|
LL | 5..15 => {},
| ^^^^^
error: unreachable pattern
- --> $DIR/reachability.rs:62:9
+ --> $DIR/reachability.rs:63:9
|
LL | 5..25 => {},
| ^^^^^
error: unreachable pattern
- --> $DIR/reachability.rs:70:9
+ --> $DIR/reachability.rs:71:9
|
LL | 5..25 => {},
| ^^^^^
error: unreachable pattern
- --> $DIR/reachability.rs:76:9
+ --> $DIR/reachability.rs:77:9
|
LL | 5..15 => {},
| ^^^^^
error: unreachable pattern
- --> $DIR/reachability.rs:83:9
+ --> $DIR/reachability.rs:84:9
|
LL | _ => {},
| - matches any value
@@ -139,16 +139,22 @@ LL | '\u{D7FF}'..='\u{E000}' => {},
| ^^^^^^^^^^^^^^^^^^^^^^^ unreachable pattern
error: unreachable pattern
- --> $DIR/reachability.rs:104:9
+ --> $DIR/reachability.rs:89:9
+ |
+LL | '\u{D7FF}'..='\u{E000}' => {},
+ | ^^^^^^^^^^^^^^^^^^^^^^^
+
+error: unreachable pattern
+ --> $DIR/reachability.rs:105:9
|
LL | &FOO => {}
| ^^^^
error: unreachable pattern
- --> $DIR/reachability.rs:105:9
+ --> $DIR/reachability.rs:106:9
|
LL | BAR => {}
| ^^^
-error: aborting due to 24 previous errors
+error: aborting due to 25 previous errors
diff --git a/tests/ui/pattern/usefulness/issue-105479-str-non-exhaustiveness.stderr b/tests/ui/pattern/usefulness/issue-105479-str-non-exhaustiveness.stderr
index 771fc320a..96500ddb9 100644
--- a/tests/ui/pattern/usefulness/issue-105479-str-non-exhaustiveness.stderr
+++ b/tests/ui/pattern/usefulness/issue-105479-str-non-exhaustiveness.stderr
@@ -12,6 +12,6 @@ LL ~ ("c", "d") => {},
LL + (&_, _) => todo!()
|
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0004`.
diff --git a/tests/ui/pattern/usefulness/issue-118437-exponential-time-on-diagonal-match.rs b/tests/ui/pattern/usefulness/issue-118437-exponential-time-on-diagonal-match.rs
new file mode 100644
index 000000000..39ad2d4ab
--- /dev/null
+++ b/tests/ui/pattern/usefulness/issue-118437-exponential-time-on-diagonal-match.rs
@@ -0,0 +1,72 @@
+// check-pass
+struct BaseCommand {
+ field01: bool,
+ field02: bool,
+ field03: bool,
+ field04: bool,
+ field05: bool,
+ field06: bool,
+ field07: bool,
+ field08: bool,
+ field09: bool,
+ field10: bool,
+ field11: bool,
+ field12: bool,
+ field13: bool,
+ field14: bool,
+ field15: bool,
+ field16: bool,
+ field17: bool,
+ field18: bool,
+ field19: bool,
+ field20: bool,
+ field21: bool,
+ field22: bool,
+ field23: bool,
+ field24: bool,
+ field25: bool,
+ field26: bool,
+ field27: bool,
+ field28: bool,
+ field29: bool,
+ field30: bool,
+}
+
+fn request_key(command: BaseCommand) {
+ match command {
+ BaseCommand { field01: true, .. } => {}
+ BaseCommand { field02: true, .. } => {}
+ BaseCommand { field03: true, .. } => {}
+ BaseCommand { field04: true, .. } => {}
+ BaseCommand { field05: true, .. } => {}
+ BaseCommand { field06: true, .. } => {}
+ BaseCommand { field07: true, .. } => {}
+ BaseCommand { field08: true, .. } => {}
+ BaseCommand { field09: true, .. } => {}
+ BaseCommand { field10: true, .. } => {}
+ BaseCommand { field11: true, .. } => {}
+ BaseCommand { field12: true, .. } => {}
+ BaseCommand { field13: true, .. } => {}
+ BaseCommand { field14: true, .. } => {}
+ BaseCommand { field15: true, .. } => {}
+ BaseCommand { field16: true, .. } => {}
+ BaseCommand { field17: true, .. } => {}
+ BaseCommand { field18: true, .. } => {}
+ BaseCommand { field19: true, .. } => {}
+ BaseCommand { field20: true, .. } => {}
+ BaseCommand { field21: true, .. } => {}
+ BaseCommand { field22: true, .. } => {}
+ BaseCommand { field23: true, .. } => {}
+ BaseCommand { field24: true, .. } => {}
+ BaseCommand { field25: true, .. } => {}
+ BaseCommand { field26: true, .. } => {}
+ BaseCommand { field27: true, .. } => {}
+ BaseCommand { field28: true, .. } => {}
+ BaseCommand { field29: true, .. } => {}
+ BaseCommand { field30: true, .. } => {}
+
+ _ => {}
+ }
+}
+
+fn main() {}
diff --git a/tests/ui/pattern/usefulness/issue-12116.stderr b/tests/ui/pattern/usefulness/issue-12116.stderr
index 7f15c4703..199bdc6ac 100644
--- a/tests/ui/pattern/usefulness/issue-12116.stderr
+++ b/tests/ui/pattern/usefulness/issue-12116.stderr
@@ -10,5 +10,5 @@ note: the lint level is defined here
LL | #![deny(unreachable_patterns)]
| ^^^^^^^^^^^^^^^^^^^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/pattern/usefulness/issue-12369.stderr b/tests/ui/pattern/usefulness/issue-12369.stderr
index aab2be78c..2b6e2e14b 100644
--- a/tests/ui/pattern/usefulness/issue-12369.stderr
+++ b/tests/ui/pattern/usefulness/issue-12369.stderr
@@ -10,5 +10,5 @@ note: the lint level is defined here
LL | #![deny(unreachable_patterns)]
| ^^^^^^^^^^^^^^^^^^^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/pattern/usefulness/issue-13727.stderr b/tests/ui/pattern/usefulness/issue-13727.stderr
index 07ca56a56..ab80c56ea 100644
--- a/tests/ui/pattern/usefulness/issue-13727.stderr
+++ b/tests/ui/pattern/usefulness/issue-13727.stderr
@@ -10,5 +10,5 @@ note: the lint level is defined here
LL | #![deny(unreachable_patterns)]
| ^^^^^^^^^^^^^^^^^^^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/pattern/usefulness/issue-15129.stderr b/tests/ui/pattern/usefulness/issue-15129.stderr
index ee8410b76..cd6c30511 100644
--- a/tests/ui/pattern/usefulness/issue-15129.stderr
+++ b/tests/ui/pattern/usefulness/issue-15129.stderr
@@ -11,6 +11,6 @@ LL ~ (T::T2(()), V::V2(b)) => (),
LL ~ (T::T1(()), V::V2(_)) | (T::T2(()), V::V1(_)) => todo!(),
|
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0004`.
diff --git a/tests/ui/pattern/usefulness/issue-2111.stderr b/tests/ui/pattern/usefulness/issue-2111.stderr
index 7f7c5a0f1..18ce7cc58 100644
--- a/tests/ui/pattern/usefulness/issue-2111.stderr
+++ b/tests/ui/pattern/usefulness/issue-2111.stderr
@@ -11,6 +11,6 @@ LL ~ (Some(_), None) | (None, Some(_)) => {},
LL + (None, None) | (Some(_), Some(_)) => todo!()
|
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0004`.
diff --git a/tests/ui/pattern/usefulness/issue-30240-b.stderr b/tests/ui/pattern/usefulness/issue-30240-b.stderr
index 59d64bc25..74d39eba9 100644
--- a/tests/ui/pattern/usefulness/issue-30240-b.stderr
+++ b/tests/ui/pattern/usefulness/issue-30240-b.stderr
@@ -10,5 +10,5 @@ note: the lint level is defined here
LL | #![deny(unreachable_patterns)]
| ^^^^^^^^^^^^^^^^^^^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/pattern/usefulness/issue-3096-1.stderr b/tests/ui/pattern/usefulness/issue-3096-1.stderr
index d8884394f..8a81116f0 100644
--- a/tests/ui/pattern/usefulness/issue-3096-1.stderr
+++ b/tests/ui/pattern/usefulness/issue-3096-1.stderr
@@ -12,6 +12,6 @@ LL + _ => todo!(),
LL ~ }
|
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0004`.
diff --git a/tests/ui/pattern/usefulness/issue-3096-2.stderr b/tests/ui/pattern/usefulness/issue-3096-2.stderr
index 2df8911ba..3eff2ee9b 100644
--- a/tests/ui/pattern/usefulness/issue-3096-2.stderr
+++ b/tests/ui/pattern/usefulness/issue-3096-2.stderr
@@ -12,6 +12,6 @@ LL + _ => todo!(),
LL ~ }
|
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0004`.
diff --git a/tests/ui/pattern/usefulness/issue-31561.stderr b/tests/ui/pattern/usefulness/issue-31561.stderr
index 5367de5e5..cc7205658 100644
--- a/tests/ui/pattern/usefulness/issue-31561.stderr
+++ b/tests/ui/pattern/usefulness/issue-31561.stderr
@@ -22,6 +22,6 @@ help: you might want to use `let else` to handle the variants that aren't matche
LL | let Thing::Foo(y) = Thing::Foo(1) else { todo!() };
| ++++++++++++++++
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0005`.
diff --git a/tests/ui/pattern/usefulness/issue-3601.rs b/tests/ui/pattern/usefulness/issue-3601.rs
index a6d2b11f4..868e8c710 100644
--- a/tests/ui/pattern/usefulness/issue-3601.rs
+++ b/tests/ui/pattern/usefulness/issue-3601.rs
@@ -31,7 +31,7 @@ fn main() {
//~^ ERROR non-exhaustive patterns
//~| NOTE the matched value is of type
//~| NOTE match arms with guards don't count towards exhaustivity
- //~| NOTE pattern `box _` not covered
+ //~| NOTE pattern `box ElementKind::HTMLImageElement(_)` not covered
//~| NOTE `Box<ElementKind>` defined here
box ElementKind::HTMLImageElement(ref d) if d.image.is_some() => true,
},
diff --git a/tests/ui/pattern/usefulness/issue-3601.stderr b/tests/ui/pattern/usefulness/issue-3601.stderr
index b8c987431..a3fcaa79b 100644
--- a/tests/ui/pattern/usefulness/issue-3601.stderr
+++ b/tests/ui/pattern/usefulness/issue-3601.stderr
@@ -1,8 +1,8 @@
-error[E0004]: non-exhaustive patterns: `box _` not covered
+error[E0004]: non-exhaustive patterns: `box ElementKind::HTMLImageElement(_)` not covered
--> $DIR/issue-3601.rs:30:44
|
LL | box NodeKind::Element(ed) => match ed.kind {
- | ^^^^^^^ pattern `box _` not covered
+ | ^^^^^^^ pattern `box ElementKind::HTMLImageElement(_)` not covered
|
note: `Box<ElementKind>` defined here
--> $SRC_DIR/alloc/src/boxed.rs:LL:COL
@@ -11,9 +11,9 @@ note: `Box<ElementKind>` defined here
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ box ElementKind::HTMLImageElement(ref d) if d.image.is_some() => true,
-LL ~ box _ => todo!(),
+LL ~ box ElementKind::HTMLImageElement(_) => todo!(),
|
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0004`.
diff --git a/tests/ui/pattern/usefulness/issue-39362.stderr b/tests/ui/pattern/usefulness/issue-39362.stderr
index 8dc534916..9cce87a1c 100644
--- a/tests/ui/pattern/usefulness/issue-39362.stderr
+++ b/tests/ui/pattern/usefulness/issue-39362.stderr
@@ -18,6 +18,6 @@ LL ~ Foo::Bar { bar: Bar::B, .. } => (),
LL ~ _ => todo!(),
|
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0004`.
diff --git a/tests/ui/pattern/usefulness/issue-40221.stderr b/tests/ui/pattern/usefulness/issue-40221.stderr
index 40b42af26..894cb95c7 100644
--- a/tests/ui/pattern/usefulness/issue-40221.stderr
+++ b/tests/ui/pattern/usefulness/issue-40221.stderr
@@ -18,6 +18,6 @@ LL ~ P::C(PC::Q) => (),
LL ~ P::C(PC::QA) => todo!(),
|
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0004`.
diff --git a/tests/ui/pattern/usefulness/issue-4321.stderr b/tests/ui/pattern/usefulness/issue-4321.stderr
index 293273174..a38f360c8 100644
--- a/tests/ui/pattern/usefulness/issue-4321.stderr
+++ b/tests/ui/pattern/usefulness/issue-4321.stderr
@@ -11,6 +11,6 @@ LL ~ (true, true) => "baz",
LL + (true, false) => todo!()
|
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0004`.
diff --git a/tests/ui/pattern/usefulness/issue-50900.stderr b/tests/ui/pattern/usefulness/issue-50900.stderr
index 7880c8925..90df1fb76 100644
--- a/tests/ui/pattern/usefulness/issue-50900.stderr
+++ b/tests/ui/pattern/usefulness/issue-50900.stderr
@@ -16,6 +16,6 @@ LL ~ Tag::ExifIFDPointer => {},
LL + Tag(Context::Exif, _) => todo!()
|
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0004`.
diff --git a/tests/ui/pattern/usefulness/issue-56379.stderr b/tests/ui/pattern/usefulness/issue-56379.stderr
index 50e13bdfd..ea21ee4e5 100644
--- a/tests/ui/pattern/usefulness/issue-56379.stderr
+++ b/tests/ui/pattern/usefulness/issue-56379.stderr
@@ -22,6 +22,6 @@ LL ~ Foo::C(true) => {},
LL + Foo::A(false) | Foo::B(false) | Foo::C(false) => todo!()
|
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0004`.
diff --git a/tests/ui/pattern/usefulness/issue-72377.stderr b/tests/ui/pattern/usefulness/issue-72377.stderr
index 123dd051d..1eaee1bd3 100644
--- a/tests/ui/pattern/usefulness/issue-72377.stderr
+++ b/tests/ui/pattern/usefulness/issue-72377.stderr
@@ -11,6 +11,6 @@ LL ~ (X::A, Some(X::C)) | (X::C, Some(X::A)) => false,
LL ~ _ => todo!(),
|
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0004`.
diff --git a/tests/ui/pattern/usefulness/issue-78123-non-exhaustive-reference.stderr b/tests/ui/pattern/usefulness/issue-78123-non-exhaustive-reference.stderr
index bf05d616d..2acde8496 100644
--- a/tests/ui/pattern/usefulness/issue-78123-non-exhaustive-reference.stderr
+++ b/tests/ui/pattern/usefulness/issue-78123-non-exhaustive-reference.stderr
@@ -18,6 +18,6 @@ LL + _ => todo!(),
LL + }
|
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0004`.
diff --git a/tests/ui/pattern/usefulness/issue-82772-match-box-as-struct.stderr b/tests/ui/pattern/usefulness/issue-82772-match-box-as-struct.stderr
index 2c8c85bb1..ba7573839 100644
--- a/tests/ui/pattern/usefulness/issue-82772-match-box-as-struct.stderr
+++ b/tests/ui/pattern/usefulness/issue-82772-match-box-as-struct.stderr
@@ -4,6 +4,6 @@ error[E0451]: field `1` of struct `Box` is private
LL | let Box { 1: _, .. }: Box<()>;
| ^^^^ private field
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0451`.
diff --git a/tests/ui/pattern/usefulness/issue-85222-types-containing-non-exhaustive-types.stderr b/tests/ui/pattern/usefulness/issue-85222-types-containing-non-exhaustive-types.stderr
index 556efcda5..c31411018 100644
--- a/tests/ui/pattern/usefulness/issue-85222-types-containing-non-exhaustive-types.stderr
+++ b/tests/ui/pattern/usefulness/issue-85222-types-containing-non-exhaustive-types.stderr
@@ -6,7 +6,6 @@ LL | match 0 {
|
= note: the matched value is of type `usize`
= note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively
- = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ 1..=usize::MAX => (),
@@ -21,7 +20,6 @@ LL | match (0usize, 0usize) {
|
= note: the matched value is of type `(usize, usize)`
= note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively
- = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ (1..=usize::MAX, 1..=usize::MAX) => (),
@@ -36,7 +34,6 @@ LL | match (0isize, 0usize) {
|
= note: the matched value is of type `(isize, usize)`
= note: `isize` does not have fixed minimum and maximum values, so half-open ranges are necessary to match exhaustively
- = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching
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
|
LL ~ (isize::MIN..=isize::MAX, 1..=usize::MAX) => (),
@@ -74,7 +71,6 @@ note: `Option<usize>` defined here
= note: not covered
= note: the matched value is of type `Option<usize>`
= note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively
- = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ None => (),
@@ -98,7 +94,6 @@ note: `Option<Option<Option<usize>>>` defined here
= note: not covered
= note: the matched value is of type `Option<Option<Option<usize>>>`
= note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively
- = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ None => (),
@@ -118,7 +113,6 @@ LL | struct A<T> {
| ^
= note: the matched value is of type `A<usize>`
= note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively
- = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ A { a: 1..=usize::MAX } => (),
@@ -138,7 +132,6 @@ LL | struct B<T, U>(T, U);
| ^
= note: the matched value is of type `B<isize, usize>`
= note: `isize` does not have fixed minimum and maximum values, so half-open ranges are necessary to match exhaustively
- = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching
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
|
LL ~ B(isize::MIN..=isize::MAX, 1..=usize::MAX) => (),
@@ -158,7 +151,6 @@ LL | struct B<T, U>(T, U);
| ^
= note: the matched value is of type `B<isize, usize>`
= note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively
- = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ B(_, 1..=usize::MAX) => (),
diff --git a/tests/ui/pattern/usefulness/match-non-exhaustive.stderr b/tests/ui/pattern/usefulness/match-non-exhaustive.stderr
index 4fa3a7292..1a0cc58f3 100644
--- a/tests/ui/pattern/usefulness/match-non-exhaustive.stderr
+++ b/tests/ui/pattern/usefulness/match-non-exhaustive.stderr
@@ -10,18 +10,18 @@ help: ensure that all possible cases are being handled by adding a match arm wit
LL | match 0 { 1 => (), i32::MIN..=0_i32 | 2_i32..=i32::MAX => todo!() }
| ++++++++++++++++++++++++++++++++++++++++++++++++
-error[E0004]: non-exhaustive patterns: `_` not covered
+error[E0004]: non-exhaustive patterns: `i32::MIN..=-1_i32` and `1_i32..=i32::MAX` not covered
--> $DIR/match-non-exhaustive.rs:3:11
|
LL | match 0 { 0 if false => () }
- | ^ pattern `_` not covered
+ | ^ patterns `i32::MIN..=-1_i32` and `1_i32..=i32::MAX` not covered
|
= note: the matched value is of type `i32`
= note: match arms with guards don't count towards exhaustivity
-help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
+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
|
-LL | match 0 { 0 if false => (), _ => todo!() }
- | ++++++++++++++
+LL | match 0 { 0 if false => (), i32::MIN..=-1_i32 | 1_i32..=i32::MAX => todo!() }
+ | +++++++++++++++++++++++++++++++++++++++++++++++++
error: aborting due to 2 previous errors
diff --git a/tests/ui/pattern/usefulness/match-privately-empty.stderr b/tests/ui/pattern/usefulness/match-privately-empty.stderr
index 45352f094..d760790df 100644
--- a/tests/ui/pattern/usefulness/match-privately-empty.stderr
+++ b/tests/ui/pattern/usefulness/match-privately-empty.stderr
@@ -16,6 +16,6 @@ LL ~ }) => {},
LL + Some(Private { misc: true, .. }) => todo!()
|
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0004`.
diff --git a/tests/ui/pattern/usefulness/match-ref-ice.stderr b/tests/ui/pattern/usefulness/match-ref-ice.stderr
index fad0940ba..0dbfa776f 100644
--- a/tests/ui/pattern/usefulness/match-ref-ice.stderr
+++ b/tests/ui/pattern/usefulness/match-ref-ice.stderr
@@ -10,5 +10,5 @@ note: the lint level is defined here
LL | #![deny(unreachable_patterns)]
| ^^^^^^^^^^^^^^^^^^^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/pattern/usefulness/match-slice-patterns.stderr b/tests/ui/pattern/usefulness/match-slice-patterns.stderr
index 63d1f38e9..30828ab6c 100644
--- a/tests/ui/pattern/usefulness/match-slice-patterns.stderr
+++ b/tests/ui/pattern/usefulness/match-slice-patterns.stderr
@@ -11,6 +11,6 @@ LL ~ &[.., Some(_), _] => {},
LL ~ &[_, Some(_), .., None, _] => todo!(),
|
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0004`.
diff --git a/tests/ui/pattern/usefulness/nested-non-exhaustive-enums.stderr b/tests/ui/pattern/usefulness/nested-non-exhaustive-enums.stderr
index 9fbd871db..a96644415 100644
--- a/tests/ui/pattern/usefulness/nested-non-exhaustive-enums.stderr
+++ b/tests/ui/pattern/usefulness/nested-non-exhaustive-enums.stderr
@@ -17,6 +17,6 @@ LL ~ None => {},
LL + Some(_) => todo!()
|
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0004`.
diff --git a/tests/ui/pattern/usefulness/refutable-pattern-in-fn-arg.stderr b/tests/ui/pattern/usefulness/refutable-pattern-in-fn-arg.stderr
index 01f077909..bd6c5002e 100644
--- a/tests/ui/pattern/usefulness/refutable-pattern-in-fn-arg.stderr
+++ b/tests/ui/pattern/usefulness/refutable-pattern-in-fn-arg.stderr
@@ -10,6 +10,6 @@ help: alternatively, you could prepend the pattern with an underscore to define
LL | let f = |_3: isize| println!("hello");
| +
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0005`.
diff --git a/tests/ui/pattern/usefulness/slice-patterns-exhaustiveness.rs b/tests/ui/pattern/usefulness/slice-patterns-exhaustiveness.rs
index 46e0da5be..97ded70fc 100644
--- a/tests/ui/pattern/usefulness/slice-patterns-exhaustiveness.rs
+++ b/tests/ui/pattern/usefulness/slice-patterns-exhaustiveness.rs
@@ -44,6 +44,10 @@ fn main() {
[] => {}
}
match s {
+ //~^ ERROR `&[]` and `&[_, ..]` not covered
+ [..] if false => {}
+ }
+ match s {
//~^ ERROR `&[_, _, ..]` not covered
[] => {}
[_] => {}
diff --git a/tests/ui/pattern/usefulness/slice-patterns-exhaustiveness.stderr b/tests/ui/pattern/usefulness/slice-patterns-exhaustiveness.stderr
index fb6ecda3c..a8786d024 100644
--- a/tests/ui/pattern/usefulness/slice-patterns-exhaustiveness.stderr
+++ b/tests/ui/pattern/usefulness/slice-patterns-exhaustiveness.stderr
@@ -89,10 +89,24 @@ LL ~ [] => {},
LL + &[_, ..] => todo!()
|
-error[E0004]: non-exhaustive patterns: `&[_, _, ..]` not covered
+error[E0004]: non-exhaustive patterns: `&[]` and `&[_, ..]` not covered
--> $DIR/slice-patterns-exhaustiveness.rs:46:11
|
LL | match s {
+ | ^ patterns `&[]` and `&[_, ..]` not covered
+ |
+ = note: the matched value is of type `&[bool]`
+ = note: match arms with guards don't count towards exhaustivity
+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
+ |
+LL ~ [..] if false => {},
+LL + &[] | &[_, ..] => todo!()
+ |
+
+error[E0004]: non-exhaustive patterns: `&[_, _, ..]` not covered
+ --> $DIR/slice-patterns-exhaustiveness.rs:50:11
+ |
+LL | match s {
| ^ pattern `&[_, _, ..]` not covered
|
= note: the matched value is of type `&[bool]`
@@ -103,7 +117,7 @@ LL + &[_, _, ..] => todo!()
|
error[E0004]: non-exhaustive patterns: `&[false, ..]` not covered
- --> $DIR/slice-patterns-exhaustiveness.rs:51:11
+ --> $DIR/slice-patterns-exhaustiveness.rs:55:11
|
LL | match s {
| ^ pattern `&[false, ..]` not covered
@@ -116,7 +130,7 @@ LL + &[false, ..] => todo!()
|
error[E0004]: non-exhaustive patterns: `&[false, _, ..]` not covered
- --> $DIR/slice-patterns-exhaustiveness.rs:56:11
+ --> $DIR/slice-patterns-exhaustiveness.rs:60:11
|
LL | match s {
| ^ pattern `&[false, _, ..]` not covered
@@ -129,7 +143,7 @@ LL + &[false, _, ..] => todo!()
|
error[E0004]: non-exhaustive patterns: `&[_, .., false]` not covered
- --> $DIR/slice-patterns-exhaustiveness.rs:62:11
+ --> $DIR/slice-patterns-exhaustiveness.rs:66:11
|
LL | match s {
| ^ pattern `&[_, .., false]` not covered
@@ -142,7 +156,7 @@ LL + &[_, .., false] => todo!()
|
error[E0004]: non-exhaustive patterns: `&[_, _, .., true]` not covered
- --> $DIR/slice-patterns-exhaustiveness.rs:69:11
+ --> $DIR/slice-patterns-exhaustiveness.rs:73:11
|
LL | match s {
| ^ pattern `&[_, _, .., true]` not covered
@@ -155,7 +169,7 @@ LL + &[_, _, .., true] => todo!()
|
error[E0004]: non-exhaustive patterns: `&[true, _, .., _]` not covered
- --> $DIR/slice-patterns-exhaustiveness.rs:76:11
+ --> $DIR/slice-patterns-exhaustiveness.rs:80:11
|
LL | match s {
| ^ pattern `&[true, _, .., _]` not covered
@@ -168,7 +182,7 @@ LL + &[true, _, .., _] => todo!()
|
error[E0004]: non-exhaustive patterns: `&[]` and `&[_, _, ..]` not covered
- --> $DIR/slice-patterns-exhaustiveness.rs:85:11
+ --> $DIR/slice-patterns-exhaustiveness.rs:89:11
|
LL | match s {
| ^ patterns `&[]` and `&[_, _, ..]` not covered
@@ -181,7 +195,7 @@ LL + &[] | &[_, _, ..] => todo!()
|
error[E0004]: non-exhaustive patterns: `&[]` and `&[_, _, ..]` not covered
- --> $DIR/slice-patterns-exhaustiveness.rs:89:11
+ --> $DIR/slice-patterns-exhaustiveness.rs:93:11
|
LL | match s {
| ^ patterns `&[]` and `&[_, _, ..]` not covered
@@ -194,7 +208,7 @@ LL + &[] | &[_, _, ..] => todo!()
|
error[E0004]: non-exhaustive patterns: `&[]` and `&[_, _, ..]` not covered
- --> $DIR/slice-patterns-exhaustiveness.rs:93:11
+ --> $DIR/slice-patterns-exhaustiveness.rs:97:11
|
LL | match s {
| ^ patterns `&[]` and `&[_, _, ..]` not covered
@@ -207,7 +221,7 @@ LL + &[] | &[_, _, ..] => todo!()
|
error[E0004]: non-exhaustive patterns: `&[]` and `&[_, _, ..]` not covered
- --> $DIR/slice-patterns-exhaustiveness.rs:98:11
+ --> $DIR/slice-patterns-exhaustiveness.rs:102:11
|
LL | match s {
| ^ patterns `&[]` and `&[_, _, ..]` not covered
@@ -220,7 +234,7 @@ LL + &[] | &[_, _, ..] => todo!()
|
error[E0004]: non-exhaustive patterns: `&[_, _, ..]` not covered
- --> $DIR/slice-patterns-exhaustiveness.rs:103:11
+ --> $DIR/slice-patterns-exhaustiveness.rs:107:11
|
LL | match s {
| ^ pattern `&[_, _, ..]` not covered
@@ -233,7 +247,7 @@ LL + &[_, _, ..] => todo!()
|
error[E0004]: non-exhaustive patterns: `&[false]` not covered
- --> $DIR/slice-patterns-exhaustiveness.rs:108:11
+ --> $DIR/slice-patterns-exhaustiveness.rs:112:11
|
LL | match s {
| ^ pattern `&[false]` not covered
@@ -246,7 +260,7 @@ LL + &[false] => todo!()
|
error[E0004]: non-exhaustive patterns: `&[false]` not covered
- --> $DIR/slice-patterns-exhaustiveness.rs:121:11
+ --> $DIR/slice-patterns-exhaustiveness.rs:125:11
|
LL | match s1 {
| ^^ pattern `&[false]` not covered
@@ -258,6 +272,6 @@ LL ~ CONST1 => {},
LL + &[false] => todo!()
|
-error: aborting due to 20 previous errors
+error: aborting due to 21 previous errors
For more information about this error, try `rustc --explain E0004`.
diff --git a/tests/ui/pattern/usefulness/slice_of_empty.rs b/tests/ui/pattern/usefulness/slice_of_empty.rs
index fe0688711..3cbd0eba5 100644
--- a/tests/ui/pattern/usefulness/slice_of_empty.rs
+++ b/tests/ui/pattern/usefulness/slice_of_empty.rs
@@ -11,12 +11,12 @@ fn foo(nevers: &[!]) {
match nevers {
&[] => (),
- &[_] => (), //~ ERROR unreachable pattern
- &[_, _, ..] => (), //~ ERROR unreachable pattern
+ &[_] => (),
+ &[_, _, ..] => (),
};
match nevers {
//~^ ERROR non-exhaustive patterns: `&[]` not covered
- &[_] => (), //~ ERROR unreachable pattern
+ &[_] => (),
};
}
diff --git a/tests/ui/pattern/usefulness/slice_of_empty.stderr b/tests/ui/pattern/usefulness/slice_of_empty.stderr
index 07bb6b3a6..d56360d4c 100644
--- a/tests/ui/pattern/usefulness/slice_of_empty.stderr
+++ b/tests/ui/pattern/usefulness/slice_of_empty.stderr
@@ -1,27 +1,3 @@
-error: unreachable pattern
- --> $DIR/slice_of_empty.rs:14:9
- |
-LL | &[_] => (),
- | ^^^^
- |
-note: the lint level is defined here
- --> $DIR/slice_of_empty.rs:3:9
- |
-LL | #![deny(unreachable_patterns)]
- | ^^^^^^^^^^^^^^^^^^^^
-
-error: unreachable pattern
- --> $DIR/slice_of_empty.rs:15:9
- |
-LL | &[_, _, ..] => (),
- | ^^^^^^^^^^^
-
-error: unreachable pattern
- --> $DIR/slice_of_empty.rs:20:9
- |
-LL | &[_] => (),
- | ^^^^
-
error[E0004]: non-exhaustive patterns: `&[]` not covered
--> $DIR/slice_of_empty.rs:18:11
|
@@ -31,9 +7,10 @@ LL | match nevers {
= note: the matched value is of type `&[!]`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
-LL | &[_] => (), &[] => todo!(),
- | ++++++++++++++++
+LL ~ &[_] => (),
+LL ~ &[] => todo!(),
+ |
-error: aborting due to 4 previous errors
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0004`.
diff --git a/tests/ui/pattern/usefulness/struct-like-enum-nonexhaustive.stderr b/tests/ui/pattern/usefulness/struct-like-enum-nonexhaustive.stderr
index 3d2b540a9..17d937bd5 100644
--- a/tests/ui/pattern/usefulness/struct-like-enum-nonexhaustive.stderr
+++ b/tests/ui/pattern/usefulness/struct-like-enum-nonexhaustive.stderr
@@ -18,6 +18,6 @@ LL ~ A::B { x: None } => {},
LL + A::B { x: Some(_) } => todo!()
|
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0004`.
diff --git a/tests/ui/pattern/usefulness/struct-pattern-match-useless.stderr b/tests/ui/pattern/usefulness/struct-pattern-match-useless.stderr
index fbee33de6..cc29c42e4 100644
--- a/tests/ui/pattern/usefulness/struct-pattern-match-useless.stderr
+++ b/tests/ui/pattern/usefulness/struct-pattern-match-useless.stderr
@@ -12,5 +12,5 @@ note: the lint level is defined here
LL | #![deny(unreachable_patterns)]
| ^^^^^^^^^^^^^^^^^^^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/pattern/usefulness/tuple-struct-nonexhaustive.stderr b/tests/ui/pattern/usefulness/tuple-struct-nonexhaustive.stderr
index ef707ed4a..0b21bd3f5 100644
--- a/tests/ui/pattern/usefulness/tuple-struct-nonexhaustive.stderr
+++ b/tests/ui/pattern/usefulness/tuple-struct-nonexhaustive.stderr
@@ -16,6 +16,6 @@ LL ~ Foo(2, b) => println!("{}", b),
LL + Foo(..=0_isize, _) | Foo(3_isize.., _) => todo!()
|
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0004`.
diff --git a/tests/ui/pattern/usefulness/unstable-gated-patterns.stderr b/tests/ui/pattern/usefulness/unstable-gated-patterns.stderr
index 4a4945156..5f3e5a739 100644
--- a/tests/ui/pattern/usefulness/unstable-gated-patterns.stderr
+++ b/tests/ui/pattern/usefulness/unstable-gated-patterns.stderr
@@ -19,6 +19,6 @@ LL ~ UnstableEnum::Stable2 => {},
LL + UnstableEnum::Unstable => todo!()
|
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0004`.