summaryrefslogtreecommitdiffstats
path: root/tests/ui/pattern
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/pattern')
-rw-r--r--tests/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr2
-rw-r--r--tests/ui/pattern/incorrect-placement-of-pattern-modifiers.fixed18
-rw-r--r--tests/ui/pattern/incorrect-placement-of-pattern-modifiers.rs18
-rw-r--r--tests/ui/pattern/incorrect-placement-of-pattern-modifiers.stderr58
-rw-r--r--tests/ui/pattern/issue-115599.rs7
-rw-r--r--tests/ui/pattern/issue-115599.stderr11
-rw-r--r--tests/ui/pattern/issue-94866.stderr4
-rw-r--r--tests/ui/pattern/non-structural-match-types.mir.stderr14
-rw-r--r--tests/ui/pattern/non-structural-match-types.rs7
-rw-r--r--tests/ui/pattern/non-structural-match-types.stderr14
-rw-r--r--tests/ui/pattern/non-structural-match-types.thir.stderr14
-rw-r--r--tests/ui/pattern/patkind-litrange-no-expr.stderr2
-rw-r--r--tests/ui/pattern/slice-patterns-irrefutable.stderr3
-rw-r--r--tests/ui/pattern/usefulness/conflicting_bindings.rs24
-rw-r--r--tests/ui/pattern/usefulness/conflicting_bindings.stderr66
-rw-r--r--tests/ui/pattern/usefulness/consts-opaque.rs55
-rw-r--r--tests/ui/pattern/usefulness/consts-opaque.stderr184
-rw-r--r--tests/ui/pattern/usefulness/doc-hidden-non-exhaustive.stderr18
-rw-r--r--tests/ui/pattern/usefulness/empty-match.exhaustive_patterns.stderr94
-rw-r--r--tests/ui/pattern/usefulness/empty-match.normal.stderr94
-rw-r--r--tests/ui/pattern/usefulness/empty-match.rs18
-rw-r--r--tests/ui/pattern/usefulness/floats.rs40
-rw-r--r--tests/ui/pattern/usefulness/floats.stderr52
-rw-r--r--tests/ui/pattern/usefulness/integer-ranges/overlapping_range_endpoints.rs20
-rw-r--r--tests/ui/pattern/usefulness/integer-ranges/overlapping_range_endpoints.stderr53
-rw-r--r--tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.allow.stderr2
-rw-r--r--tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.deny.stderr140
-rw-r--r--tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.rs6
-rw-r--r--tests/ui/pattern/usefulness/integer-ranges/precise_pointer_matching-message.rs10
-rw-r--r--tests/ui/pattern/usefulness/integer-ranges/precise_pointer_matching-message.stderr18
-rw-r--r--tests/ui/pattern/usefulness/issue-35609.stderr3
-rw-r--r--tests/ui/pattern/usefulness/issue-39362.stderr6
-rw-r--r--tests/ui/pattern/usefulness/issue-40221.stderr6
-rw-r--r--tests/ui/pattern/usefulness/issue-56379.stderr10
-rw-r--r--tests/ui/pattern/usefulness/issue-85222-types-containing-non-exhaustive-types.rs16
-rw-r--r--tests/ui/pattern/usefulness/issue-85222-types-containing-non-exhaustive-types.stderr68
-rw-r--r--tests/ui/pattern/usefulness/non-exhaustive-defined-here.rs18
-rw-r--r--tests/ui/pattern/usefulness/non-exhaustive-defined-here.stderr54
-rw-r--r--tests/ui/pattern/usefulness/non-exhaustive-match-nested.stderr4
-rw-r--r--tests/ui/pattern/usefulness/non-exhaustive-match.stderr8
-rw-r--r--tests/ui/pattern/usefulness/non-exhaustive-pattern-witness.rs53
-rw-r--r--tests/ui/pattern/usefulness/non-exhaustive-pattern-witness.stderr75
-rw-r--r--tests/ui/pattern/usefulness/refutable-pattern-errors.rs4
-rw-r--r--tests/ui/pattern/usefulness/refutable-pattern-errors.stderr4
-rw-r--r--tests/ui/pattern/usefulness/refutable-pattern-in-fn-arg.rs2
-rw-r--r--tests/ui/pattern/usefulness/refutable-pattern-in-fn-arg.stderr2
-rw-r--r--tests/ui/pattern/usefulness/slice_of_empty.rs22
-rw-r--r--tests/ui/pattern/usefulness/slice_of_empty.stderr39
-rw-r--r--tests/ui/pattern/usefulness/stable-gated-patterns.stderr6
-rw-r--r--tests/ui/pattern/usefulness/struct-like-enum-nonexhaustive.stderr6
-rw-r--r--tests/ui/pattern/usefulness/tuple-struct-nonexhaustive.stderr10
-rw-r--r--tests/ui/pattern/usefulness/unstable-gated-patterns.stderr6
52 files changed, 954 insertions, 534 deletions
diff --git a/tests/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr b/tests/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr
index c0a6558a1..0b4324876 100644
--- a/tests/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr
+++ b/tests/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr
@@ -307,6 +307,7 @@ LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false
| ^ move occurs because `b` has type `&mut U`, which does not implement the `Copy` trait
|
= note: variables bound in patterns cannot be moved from until after the end of the pattern guard
+ = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0507]: cannot move out of `a` in pattern guard
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:109:66
@@ -323,6 +324,7 @@ LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false
| ^ move occurs because `a` has type `&mut Result<U, U>`, which does not implement the `Copy` trait
|
= note: variables bound in patterns cannot be moved from until after the end of the pattern guard
+ = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:117:9
diff --git a/tests/ui/pattern/incorrect-placement-of-pattern-modifiers.fixed b/tests/ui/pattern/incorrect-placement-of-pattern-modifiers.fixed
new file mode 100644
index 000000000..cf6c2a24f
--- /dev/null
+++ b/tests/ui/pattern/incorrect-placement-of-pattern-modifiers.fixed
@@ -0,0 +1,18 @@
+// run-rustfix
+struct S {
+ field_name: (),
+}
+
+fn main() {
+ match (S {field_name: ()}) {
+ S {field_name: ref _foo} => {} //~ ERROR expected `,`
+ }
+ match (S {field_name: ()}) {
+ S {field_name: mut _foo} => {} //~ ERROR expected `,`
+ }
+ match (S {field_name: ()}) {
+ S {field_name: ref mut _foo} => {} //~ ERROR expected `,`
+ }
+ // Verify that we recover enough to run typeck.
+ let _: usize = 3usize; //~ ERROR mismatched types
+}
diff --git a/tests/ui/pattern/incorrect-placement-of-pattern-modifiers.rs b/tests/ui/pattern/incorrect-placement-of-pattern-modifiers.rs
new file mode 100644
index 000000000..98772c118
--- /dev/null
+++ b/tests/ui/pattern/incorrect-placement-of-pattern-modifiers.rs
@@ -0,0 +1,18 @@
+// run-rustfix
+struct S {
+ field_name: (),
+}
+
+fn main() {
+ match (S {field_name: ()}) {
+ S {ref field_name: _foo} => {} //~ ERROR expected `,`
+ }
+ match (S {field_name: ()}) {
+ S {mut field_name: _foo} => {} //~ ERROR expected `,`
+ }
+ match (S {field_name: ()}) {
+ S {ref mut field_name: _foo} => {} //~ ERROR expected `,`
+ }
+ // Verify that we recover enough to run typeck.
+ let _: usize = 3u8; //~ ERROR mismatched types
+}
diff --git a/tests/ui/pattern/incorrect-placement-of-pattern-modifiers.stderr b/tests/ui/pattern/incorrect-placement-of-pattern-modifiers.stderr
new file mode 100644
index 000000000..e80789253
--- /dev/null
+++ b/tests/ui/pattern/incorrect-placement-of-pattern-modifiers.stderr
@@ -0,0 +1,58 @@
+error: expected `,`
+ --> $DIR/incorrect-placement-of-pattern-modifiers.rs:8:26
+ |
+LL | S {ref field_name: _foo} => {}
+ | - ^
+ | |
+ | while parsing the fields for this pattern
+ |
+help: the pattern modifiers belong after the `:`
+ |
+LL - S {ref field_name: _foo} => {}
+LL + S {field_name: ref _foo} => {}
+ |
+
+error: expected `,`
+ --> $DIR/incorrect-placement-of-pattern-modifiers.rs:11:26
+ |
+LL | S {mut field_name: _foo} => {}
+ | - ^
+ | |
+ | while parsing the fields for this pattern
+ |
+help: the pattern modifiers belong after the `:`
+ |
+LL - S {mut field_name: _foo} => {}
+LL + S {field_name: mut _foo} => {}
+ |
+
+error: expected `,`
+ --> $DIR/incorrect-placement-of-pattern-modifiers.rs:14:30
+ |
+LL | S {ref mut field_name: _foo} => {}
+ | - ^
+ | |
+ | while parsing the fields for this pattern
+ |
+help: the pattern modifiers belong after the `:`
+ |
+LL - S {ref mut field_name: _foo} => {}
+LL + S {field_name: ref mut _foo} => {}
+ |
+
+error[E0308]: mismatched types
+ --> $DIR/incorrect-placement-of-pattern-modifiers.rs:17:20
+ |
+LL | let _: usize = 3u8;
+ | ----- ^^^ expected `usize`, found `u8`
+ | |
+ | expected due to this
+ |
+help: change the type of the numeric literal from `u8` to `usize`
+ |
+LL | let _: usize = 3usize;
+ | ~~~~~
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/pattern/issue-115599.rs b/tests/ui/pattern/issue-115599.rs
new file mode 100644
index 000000000..7a222b90a
--- /dev/null
+++ b/tests/ui/pattern/issue-115599.rs
@@ -0,0 +1,7 @@
+const CONST_STRING: String = String::new();
+
+fn main() {
+ let empty_str = String::from("");
+ if let CONST_STRING = empty_str {}
+ //~^ ERROR to use a constant of type `Vec<u8>` in a pattern, `Vec<u8>` must be annotated with `#[derive(PartialEq, Eq)]`
+}
diff --git a/tests/ui/pattern/issue-115599.stderr b/tests/ui/pattern/issue-115599.stderr
new file mode 100644
index 000000000..e6cb6c1dd
--- /dev/null
+++ b/tests/ui/pattern/issue-115599.stderr
@@ -0,0 +1,11 @@
+error: to use a constant of type `Vec<u8>` in a pattern, `Vec<u8>` must be annotated with `#[derive(PartialEq, Eq)]`
+ --> $DIR/issue-115599.rs:5:12
+ |
+LL | if let CONST_STRING = empty_str {}
+ | ^^^^^^^^^^^^
+ |
+ = 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
+
diff --git a/tests/ui/pattern/issue-94866.stderr b/tests/ui/pattern/issue-94866.stderr
index b3c17ce89..dee4b3f55 100644
--- a/tests/ui/pattern/issue-94866.stderr
+++ b/tests/ui/pattern/issue-94866.stderr
@@ -5,10 +5,10 @@ LL | match Enum::A {
| ^^^^^^^ pattern `Enum::B` not covered
|
note: `Enum` defined here
- --> $DIR/issue-94866.rs:7:16
+ --> $DIR/issue-94866.rs:7:6
|
LL | enum Enum { A, B }
- | ---- ^ not covered
+ | ^^^^ - not covered
= note: the matched value is of type `Enum`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
diff --git a/tests/ui/pattern/non-structural-match-types.mir.stderr b/tests/ui/pattern/non-structural-match-types.mir.stderr
new file mode 100644
index 000000000..7a9e5b7e0
--- /dev/null
+++ b/tests/ui/pattern/non-structural-match-types.mir.stderr
@@ -0,0 +1,14 @@
+error: `{closure@$DIR/non-structural-match-types.rs:12:17: 12:19}` cannot be used in patterns
+ --> $DIR/non-structural-match-types.rs:12:9
+ |
+LL | const { || {} } => {}
+ | ^^^^^^^^^^^^^^^
+
+error: `{async block@$DIR/non-structural-match-types.rs:15:17: 15:25}` cannot be used in patterns
+ --> $DIR/non-structural-match-types.rs:15:9
+ |
+LL | const { async {} } => {}
+ | ^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
diff --git a/tests/ui/pattern/non-structural-match-types.rs b/tests/ui/pattern/non-structural-match-types.rs
index 5c3315473..fb7779fa8 100644
--- a/tests/ui/pattern/non-structural-match-types.rs
+++ b/tests/ui/pattern/non-structural-match-types.rs
@@ -1,4 +1,7 @@
// edition:2021
+// revisions: mir thir
+// [thir]compile-flags: -Z thir-unsafeck
+
#![allow(incomplete_features)]
#![allow(unreachable_code)]
#![feature(const_async_blocks)]
@@ -6,9 +9,9 @@
fn main() {
match loop {} {
- const { || {} } => {}, //~ ERROR cannot be used in patterns
+ const { || {} } => {} //~ ERROR cannot be used in patterns
}
match loop {} {
- const { async {} } => {}, //~ ERROR cannot be used in patterns
+ const { async {} } => {} //~ ERROR cannot be used in patterns
}
}
diff --git a/tests/ui/pattern/non-structural-match-types.stderr b/tests/ui/pattern/non-structural-match-types.stderr
deleted file mode 100644
index 43d92775e..000000000
--- a/tests/ui/pattern/non-structural-match-types.stderr
+++ /dev/null
@@ -1,14 +0,0 @@
-error: `{closure@$DIR/non-structural-match-types.rs:9:17: 9:19}` cannot be used in patterns
- --> $DIR/non-structural-match-types.rs:9:9
- |
-LL | const { || {} } => {},
- | ^^^^^^^^^^^^^^^
-
-error: `{async block@$DIR/non-structural-match-types.rs:12:17: 12:25}` cannot be used in patterns
- --> $DIR/non-structural-match-types.rs:12:9
- |
-LL | const { async {} } => {},
- | ^^^^^^^^^^^^^^^^^^
-
-error: aborting due to 2 previous errors
-
diff --git a/tests/ui/pattern/non-structural-match-types.thir.stderr b/tests/ui/pattern/non-structural-match-types.thir.stderr
new file mode 100644
index 000000000..7a9e5b7e0
--- /dev/null
+++ b/tests/ui/pattern/non-structural-match-types.thir.stderr
@@ -0,0 +1,14 @@
+error: `{closure@$DIR/non-structural-match-types.rs:12:17: 12:19}` cannot be used in patterns
+ --> $DIR/non-structural-match-types.rs:12:9
+ |
+LL | const { || {} } => {}
+ | ^^^^^^^^^^^^^^^
+
+error: `{async block@$DIR/non-structural-match-types.rs:15:17: 15:25}` cannot be used in patterns
+ --> $DIR/non-structural-match-types.rs:15:9
+ |
+LL | const { async {} } => {}
+ | ^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
diff --git a/tests/ui/pattern/patkind-litrange-no-expr.stderr b/tests/ui/pattern/patkind-litrange-no-expr.stderr
index eb1ee7e45..45a261489 100644
--- a/tests/ui/pattern/patkind-litrange-no-expr.stderr
+++ b/tests/ui/pattern/patkind-litrange-no-expr.stderr
@@ -9,6 +9,8 @@ error: arbitrary expressions aren't allowed in patterns
|
LL | Arith = 1 + 1,
| ^^^^^
+ |
+ = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 2 previous errors
diff --git a/tests/ui/pattern/slice-patterns-irrefutable.stderr b/tests/ui/pattern/slice-patterns-irrefutable.stderr
index fac99534f..e98ee28d6 100644
--- a/tests/ui/pattern/slice-patterns-irrefutable.stderr
+++ b/tests/ui/pattern/slice-patterns-irrefutable.stderr
@@ -3,6 +3,9 @@ error[E0282]: type annotations needed for `[_; 3]`
|
LL | let b;
| ^
+LL |
+LL | [a, b] = Default::default();
+ | - type must be known at this point
|
help: consider giving `b` an explicit type, where the placeholders `_` are specified
|
diff --git a/tests/ui/pattern/usefulness/conflicting_bindings.rs b/tests/ui/pattern/usefulness/conflicting_bindings.rs
new file mode 100644
index 000000000..0b3e7ce9e
--- /dev/null
+++ b/tests/ui/pattern/usefulness/conflicting_bindings.rs
@@ -0,0 +1,24 @@
+#![feature(if_let_guard, let_chains)]
+
+fn main() {
+ let mut x = Some(String::new());
+ let ref mut y @ ref mut z = x;
+ //~^ ERROR: mutable more than once
+ let Some(ref mut y @ ref mut z) = x else { return };
+ //~^ ERROR: mutable more than once
+ if let Some(ref mut y @ ref mut z) = x {}
+ //~^ ERROR: mutable more than once
+ if let Some(ref mut y @ ref mut z) = x && true {}
+ //~^ ERROR: mutable more than once
+ while let Some(ref mut y @ ref mut z) = x {}
+ //~^ ERROR: mutable more than once
+ while let Some(ref mut y @ ref mut z) = x && true {}
+ //~^ ERROR: mutable more than once
+ match x {
+ ref mut y @ ref mut z => {} //~ ERROR: mutable more than once
+ }
+ match () {
+ () if let Some(ref mut y @ ref mut z) = x => {} //~ ERROR: mutable more than once
+ _ => {}
+ }
+}
diff --git a/tests/ui/pattern/usefulness/conflicting_bindings.stderr b/tests/ui/pattern/usefulness/conflicting_bindings.stderr
new file mode 100644
index 000000000..679fc83e7
--- /dev/null
+++ b/tests/ui/pattern/usefulness/conflicting_bindings.stderr
@@ -0,0 +1,66 @@
+error: cannot borrow value as mutable more than once at a time
+ --> $DIR/conflicting_bindings.rs:5:9
+ |
+LL | let ref mut y @ ref mut z = x;
+ | ^^^^^^^^^ --------- value is mutably borrowed by `z` here
+ | |
+ | value is mutably borrowed by `y` here
+
+error: cannot borrow value as mutable more than once at a time
+ --> $DIR/conflicting_bindings.rs:7:14
+ |
+LL | let Some(ref mut y @ ref mut z) = x else { return };
+ | ^^^^^^^^^ --------- value is mutably borrowed by `z` here
+ | |
+ | value is mutably borrowed by `y` here
+
+error: cannot borrow value as mutable more than once at a time
+ --> $DIR/conflicting_bindings.rs:9:17
+ |
+LL | if let Some(ref mut y @ ref mut z) = x {}
+ | ^^^^^^^^^ --------- value is mutably borrowed by `z` here
+ | |
+ | value is mutably borrowed by `y` here
+
+error: cannot borrow value as mutable more than once at a time
+ --> $DIR/conflicting_bindings.rs:11:17
+ |
+LL | if let Some(ref mut y @ ref mut z) = x && true {}
+ | ^^^^^^^^^ --------- value is mutably borrowed by `z` here
+ | |
+ | value is mutably borrowed by `y` here
+
+error: cannot borrow value as mutable more than once at a time
+ --> $DIR/conflicting_bindings.rs:13:20
+ |
+LL | while let Some(ref mut y @ ref mut z) = x {}
+ | ^^^^^^^^^ --------- value is mutably borrowed by `z` here
+ | |
+ | value is mutably borrowed by `y` here
+
+error: cannot borrow value as mutable more than once at a time
+ --> $DIR/conflicting_bindings.rs:15:20
+ |
+LL | while let Some(ref mut y @ ref mut z) = x && true {}
+ | ^^^^^^^^^ --------- value is mutably borrowed by `z` here
+ | |
+ | value is mutably borrowed by `y` here
+
+error: cannot borrow value as mutable more than once at a time
+ --> $DIR/conflicting_bindings.rs:18:9
+ |
+LL | ref mut y @ ref mut z => {}
+ | ^^^^^^^^^ --------- value is mutably borrowed by `z` here
+ | |
+ | value is mutably borrowed by `y` here
+
+error: cannot borrow value as mutable more than once at a time
+ --> $DIR/conflicting_bindings.rs:21:24
+ |
+LL | () if let Some(ref mut y @ ref mut z) = x => {}
+ | ^^^^^^^^^ --------- value is mutably borrowed by `z` here
+ | |
+ | value is mutably borrowed by `y` here
+
+error: aborting due to 8 previous errors
+
diff --git a/tests/ui/pattern/usefulness/consts-opaque.rs b/tests/ui/pattern/usefulness/consts-opaque.rs
index c10c6205a..27e305a39 100644
--- a/tests/ui/pattern/usefulness/consts-opaque.rs
+++ b/tests/ui/pattern/usefulness/consts-opaque.rs
@@ -30,15 +30,13 @@ fn main() {
match FOO {
FOO => {}
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
- _ => {} // should not be emitting unreachable warning
- //~^ ERROR unreachable pattern
+ _ => {}
}
match FOO_REF {
FOO_REF => {}
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
- Foo(_) => {} // should not be emitting unreachable warning
- //~^ ERROR unreachable pattern
+ Foo(_) => {}
}
// This used to cause an ICE (https://github.com/rust-lang/rust/issues/78071)
@@ -51,39 +49,31 @@ fn main() {
match BAR {
Bar => {}
- BAR => {} // should not be emitting unreachable warning
+ BAR => {}
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
- //~| ERROR unreachable pattern
_ => {}
- //~^ ERROR unreachable pattern
}
match BAR {
BAR => {}
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
- Bar => {} // should not be emitting unreachable warning
- //~^ ERROR unreachable pattern
+ Bar => {}
_ => {}
- //~^ ERROR unreachable pattern
}
match BAR {
BAR => {}
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
- BAR => {} // should not be emitting unreachable warning
+ BAR => {}
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
- //~| ERROR unreachable pattern
- _ => {} // should not be emitting unreachable warning
- //~^ ERROR unreachable pattern
+ _ => {}
}
match BAZ {
BAZ => {}
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
- Baz::Baz1 => {} // should not be emitting unreachable warning
- //~^ ERROR unreachable pattern
+ Baz::Baz1 => {}
_ => {}
- //~^ ERROR unreachable pattern
}
match BAZ {
@@ -91,16 +81,13 @@ fn main() {
BAZ => {}
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
_ => {}
- //~^ ERROR unreachable pattern
}
match BAZ {
BAZ => {}
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
- Baz::Baz2 => {} // should not be emitting unreachable warning
- //~^ ERROR unreachable pattern
- _ => {} // should not be emitting unreachable warning
- //~^ ERROR unreachable pattern
+ Baz::Baz2 => {}
+ _ => {}
}
type Quux = fn(usize, usize) -> usize;
@@ -108,8 +95,10 @@ fn main() {
const QUUX: Quux = quux;
match QUUX {
- QUUX => {}
- QUUX => {}
+ QUUX => {} //~WARN behave unpredictably
+ //~| previously accepted
+ QUUX => {} //~WARN behave unpredictably
+ //~| previously accepted
_ => {}
}
@@ -118,14 +107,17 @@ fn main() {
const WRAPQUUX: Wrap<Quux> = Wrap(quux);
match WRAPQUUX {
- WRAPQUUX => {}
- WRAPQUUX => {}
+ WRAPQUUX => {} //~WARN behave unpredictably
+ //~| previously accepted
+ WRAPQUUX => {} //~WARN behave unpredictably
+ //~| previously accepted
Wrap(_) => {}
}
match WRAPQUUX {
Wrap(_) => {}
- WRAPQUUX => {}
+ WRAPQUUX => {} //~WARN behave unpredictably
+ //~| previously accepted
}
match WRAPQUUX {
@@ -134,7 +126,8 @@ fn main() {
match WRAPQUUX {
//~^ ERROR: non-exhaustive patterns: `Wrap(_)` not covered
- WRAPQUUX => {}
+ WRAPQUUX => {} //~WARN behave unpredictably
+ //~| previously accepted
}
#[derive(PartialEq, Eq)]
@@ -145,9 +138,11 @@ fn main() {
const WHOKNOWSQUUX: WhoKnows<Quux> = WhoKnows::Yay(quux);
match WHOKNOWSQUUX {
- WHOKNOWSQUUX => {}
+ WHOKNOWSQUUX => {} //~WARN behave unpredictably
+ //~| previously accepted
WhoKnows::Yay(_) => {}
- WHOKNOWSQUUX => {}
+ WHOKNOWSQUUX => {} //~WARN behave unpredictably
+ //~| previously accepted
WhoKnows::Nope => {}
}
}
diff --git a/tests/ui/pattern/usefulness/consts-opaque.stderr b/tests/ui/pattern/usefulness/consts-opaque.stderr
index e01b06ccc..09f72ba92 100644
--- a/tests/ui/pattern/usefulness/consts-opaque.stderr
+++ b/tests/ui/pattern/usefulness/consts-opaque.stderr
@@ -8,7 +8,7 @@ LL | FOO => {}
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq, Eq)]`
- --> $DIR/consts-opaque.rs:38:9
+ --> $DIR/consts-opaque.rs:37:9
|
LL | FOO_REF => {}
| ^^^^^^^
@@ -17,7 +17,7 @@ LL | FOO_REF => {}
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
warning: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq, Eq)]`
- --> $DIR/consts-opaque.rs:46:9
+ --> $DIR/consts-opaque.rs:44:9
|
LL | FOO_REF_REF => {}
| ^^^^^^^^^^^
@@ -29,16 +29,16 @@ LL | FOO_REF_REF => {}
= note: `#[warn(indirect_structural_match)]` on by default
error: to use a constant of type `Bar` in a pattern, `Bar` must be annotated with `#[derive(PartialEq, Eq)]`
- --> $DIR/consts-opaque.rs:54:9
+ --> $DIR/consts-opaque.rs:52:9
|
-LL | BAR => {} // should not be emitting unreachable warning
+LL | BAR => {}
| ^^^
|
= 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: to use a constant of type `Bar` in a pattern, `Bar` must be annotated with `#[derive(PartialEq, Eq)]`
- --> $DIR/consts-opaque.rs:62:9
+ --> $DIR/consts-opaque.rs:58:9
|
LL | BAR => {}
| ^^^
@@ -47,7 +47,7 @@ LL | BAR => {}
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
error: to use a constant of type `Bar` in a pattern, `Bar` must be annotated with `#[derive(PartialEq, Eq)]`
- --> $DIR/consts-opaque.rs:71:9
+ --> $DIR/consts-opaque.rs:65:9
|
LL | BAR => {}
| ^^^
@@ -56,16 +56,16 @@ LL | BAR => {}
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
error: to use a constant of type `Bar` in a pattern, `Bar` must be annotated with `#[derive(PartialEq, Eq)]`
- --> $DIR/consts-opaque.rs:73:9
+ --> $DIR/consts-opaque.rs:67:9
|
-LL | BAR => {} // should not be emitting unreachable warning
+LL | BAR => {}
| ^^^
|
= 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: to use a constant of type `Baz` in a pattern, `Baz` must be annotated with `#[derive(PartialEq, Eq)]`
- --> $DIR/consts-opaque.rs:81:9
+ --> $DIR/consts-opaque.rs:73:9
|
LL | BAZ => {}
| ^^^
@@ -74,7 +74,7 @@ LL | BAZ => {}
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
error: to use a constant of type `Baz` in a pattern, `Baz` must be annotated with `#[derive(PartialEq, Eq)]`
- --> $DIR/consts-opaque.rs:91:9
+ --> $DIR/consts-opaque.rs:81:9
|
LL | BAZ => {}
| ^^^
@@ -83,7 +83,7 @@ LL | BAZ => {}
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
error: to use a constant of type `Baz` in a pattern, `Baz` must be annotated with `#[derive(PartialEq, Eq)]`
- --> $DIR/consts-opaque.rs:98:9
+ --> $DIR/consts-opaque.rs:87:9
|
LL | BAZ => {}
| ^^^
@@ -91,146 +91,96 @@ LL | BAZ => {}
= 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: unreachable pattern
- --> $DIR/consts-opaque.rs:33:9
- |
-LL | FOO => {}
- | --- matches any value
-LL |
-LL | _ => {} // should not be emitting unreachable warning
- | ^ unreachable pattern
+warning: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
+ --> $DIR/consts-opaque.rs:98:9
|
-note: the lint level is defined here
- --> $DIR/consts-opaque.rs:6:9
+LL | QUUX => {}
+ | ^^^^
|
-LL | #![deny(unreachable_patterns)]
- | ^^^^^^^^^^^^^^^^^^^^
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/70861>
+ = note: `#[warn(pointer_structural_match)]` on by default
-error: unreachable pattern
- --> $DIR/consts-opaque.rs:40:9
+warning: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
+ --> $DIR/consts-opaque.rs:100:9
|
-LL | FOO_REF => {}
- | ------- matches any value
-LL |
-LL | Foo(_) => {} // should not be emitting unreachable warning
- | ^^^^^^ unreachable pattern
-
-error: unreachable pattern
- --> $DIR/consts-opaque.rs:54:9
+LL | QUUX => {}
+ | ^^^^
|
-LL | Bar => {}
- | --- matches any value
-LL | BAR => {} // should not be emitting unreachable warning
- | ^^^ unreachable pattern
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/70861>
-error: unreachable pattern
- --> $DIR/consts-opaque.rs:57:9
+warning: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
+ --> $DIR/consts-opaque.rs:110:9
|
-LL | Bar => {}
- | --- matches any value
-...
-LL | _ => {}
- | ^ unreachable pattern
-
-error: unreachable pattern
- --> $DIR/consts-opaque.rs:64:9
+LL | WRAPQUUX => {}
+ | ^^^^^^^^
|
-LL | BAR => {}
- | --- matches any value
-LL |
-LL | Bar => {} // should not be emitting unreachable warning
- | ^^^ unreachable pattern
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/70861>
-error: unreachable pattern
- --> $DIR/consts-opaque.rs:66:9
+warning: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
+ --> $DIR/consts-opaque.rs:112:9
|
-LL | BAR => {}
- | --- matches any value
-...
-LL | _ => {}
- | ^ unreachable pattern
-
-error: unreachable pattern
- --> $DIR/consts-opaque.rs:73:9
+LL | WRAPQUUX => {}
+ | ^^^^^^^^
|
-LL | BAR => {}
- | --- matches any value
-LL |
-LL | BAR => {} // should not be emitting unreachable warning
- | ^^^ unreachable pattern
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/70861>
-error: unreachable pattern
- --> $DIR/consts-opaque.rs:76:9
+warning: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
+ --> $DIR/consts-opaque.rs:119:9
|
-LL | BAR => {}
- | --- matches any value
-...
-LL | _ => {} // should not be emitting unreachable warning
- | ^ unreachable pattern
-
-error: unreachable pattern
- --> $DIR/consts-opaque.rs:83:9
+LL | WRAPQUUX => {}
+ | ^^^^^^^^
|
-LL | BAZ => {}
- | --- matches any value
-LL |
-LL | Baz::Baz1 => {} // should not be emitting unreachable warning
- | ^^^^^^^^^ unreachable pattern
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/70861>
-error: unreachable pattern
- --> $DIR/consts-opaque.rs:85:9
+warning: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
+ --> $DIR/consts-opaque.rs:129:9
|
-LL | BAZ => {}
- | --- matches any value
-...
-LL | _ => {}
- | ^ unreachable pattern
-
-error: unreachable pattern
- --> $DIR/consts-opaque.rs:93:9
+LL | WRAPQUUX => {}
+ | ^^^^^^^^
|
-LL | BAZ => {}
- | --- matches any value
-LL |
-LL | _ => {}
- | ^ unreachable pattern
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/70861>
-error: unreachable pattern
- --> $DIR/consts-opaque.rs:100:9
+warning: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
+ --> $DIR/consts-opaque.rs:141:9
|
-LL | BAZ => {}
- | --- matches any value
-LL |
-LL | Baz::Baz2 => {} // should not be emitting unreachable warning
- | ^^^^^^^^^ unreachable pattern
+LL | WHOKNOWSQUUX => {}
+ | ^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/70861>
-error: unreachable pattern
- --> $DIR/consts-opaque.rs:102:9
+warning: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
+ --> $DIR/consts-opaque.rs:144:9
|
-LL | BAZ => {}
- | --- matches any value
-...
-LL | _ => {} // should not be emitting unreachable warning
- | ^ unreachable pattern
+LL | WHOKNOWSQUUX => {}
+ | ^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/70861>
error[E0004]: non-exhaustive patterns: `Wrap(_)` not covered
- --> $DIR/consts-opaque.rs:135:11
+ --> $DIR/consts-opaque.rs:127:11
|
LL | match WRAPQUUX {
| ^^^^^^^^ pattern `Wrap(_)` not covered
|
note: `Wrap<fn(usize, usize) -> usize>` defined here
- --> $DIR/consts-opaque.rs:117:12
+ --> $DIR/consts-opaque.rs:106:12
|
LL | struct Wrap<T>(T);
| ^^^^
= note: the matched value is of type `Wrap<fn(usize, usize) -> usize>`
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 ~ WRAPQUUX => {},
-LL + Wrap(_) => todo!()
- |
+LL | WRAPQUUX => {}, Wrap(_) => todo!()
+ | ++++++++++++++++++++
-error: aborting due to 23 previous errors; 1 warning emitted
+error: aborting due to 10 previous errors; 9 warnings emitted
For more information about this error, try `rustc --explain E0004`.
diff --git a/tests/ui/pattern/usefulness/doc-hidden-non-exhaustive.stderr b/tests/ui/pattern/usefulness/doc-hidden-non-exhaustive.stderr
index ff29de03d..24f3eaa52 100644
--- a/tests/ui/pattern/usefulness/doc-hidden-non-exhaustive.stderr
+++ b/tests/ui/pattern/usefulness/doc-hidden-non-exhaustive.stderr
@@ -23,13 +23,13 @@ LL | match HiddenEnum::A {
| ^^^^^^^^^^^^^ pattern `HiddenEnum::B` not covered
|
note: `HiddenEnum` defined here
- --> $DIR/auxiliary/hidden.rs:3:5
+ --> $DIR/auxiliary/hidden.rs:1:1
|
LL | pub enum HiddenEnum {
- | -------------------
+ | ^^^^^^^^^^^^^^^^^^^
LL | A,
LL | B,
- | ^ not covered
+ | - not covered
= note: the matched value is of type `HiddenEnum`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
@@ -44,13 +44,13 @@ LL | match HiddenEnum::A {
| ^^^^^^^^^^^^^ patterns `HiddenEnum::B` and `_` not covered
|
note: `HiddenEnum` defined here
- --> $DIR/auxiliary/hidden.rs:3:5
+ --> $DIR/auxiliary/hidden.rs:1:1
|
LL | pub enum HiddenEnum {
- | -------------------
+ | ^^^^^^^^^^^^^^^^^^^
LL | A,
LL | B,
- | ^ not covered
+ | - not covered
= note: the matched value is of type `HiddenEnum`
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
|
@@ -83,13 +83,13 @@ LL | match InCrate::A {
| ^^^^^^^^^^ pattern `InCrate::C` not covered
|
note: `InCrate` defined here
- --> $DIR/doc-hidden-non-exhaustive.rs:11:5
+ --> $DIR/doc-hidden-non-exhaustive.rs:7:6
|
LL | enum InCrate {
- | -------
+ | ^^^^^^^
...
LL | C,
- | ^ not covered
+ | - not covered
= note: the matched value is of type `InCrate`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
diff --git a/tests/ui/pattern/usefulness/empty-match.exhaustive_patterns.stderr b/tests/ui/pattern/usefulness/empty-match.exhaustive_patterns.stderr
index 5b81a8c3d..8f9bd5bde 100644
--- a/tests/ui/pattern/usefulness/empty-match.exhaustive_patterns.stderr
+++ b/tests/ui/pattern/usefulness/empty-match.exhaustive_patterns.stderr
@@ -1,5 +1,5 @@
error: unreachable pattern
- --> $DIR/empty-match.rs:58:9
+ --> $DIR/empty-match.rs:68:9
|
LL | _ => {},
| ^
@@ -11,25 +11,25 @@ LL | #![deny(unreachable_patterns)]
| ^^^^^^^^^^^^^^^^^^^^
error: unreachable pattern
- --> $DIR/empty-match.rs:61:9
+ --> $DIR/empty-match.rs:71:9
|
LL | _ if false => {},
| ^
error: unreachable pattern
- --> $DIR/empty-match.rs:68:9
+ --> $DIR/empty-match.rs:78:9
|
LL | _ => {},
| ^
error: unreachable pattern
- --> $DIR/empty-match.rs:71:9
+ --> $DIR/empty-match.rs:81:9
|
LL | _ if false => {},
| ^
error[E0005]: refutable pattern in local binding
- --> $DIR/empty-match.rs:76:9
+ --> $DIR/empty-match.rs:86:9
|
LL | let None = x;
| ^^^^ pattern `Some(_)` not covered
@@ -44,19 +44,19 @@ LL | if let None = x { todo!() };
| ++ +++++++++++
error: unreachable pattern
- --> $DIR/empty-match.rs:88:9
+ --> $DIR/empty-match.rs:98:9
|
LL | _ => {},
| ^
error: unreachable pattern
- --> $DIR/empty-match.rs:91:9
+ --> $DIR/empty-match.rs:101:9
|
LL | _ if false => {},
| ^
error[E0004]: non-exhaustive patterns: type `u8` is non-empty
- --> $DIR/empty-match.rs:109:20
+ --> $DIR/empty-match.rs:119:20
|
LL | match_no_arms!(0u8);
| ^^^
@@ -65,7 +65,7 @@ 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:111:20
+ --> $DIR/empty-match.rs:121:20
|
LL | match_no_arms!(NonEmptyStruct1);
| ^^^^^^^^^^^^^^^
@@ -79,7 +79,7 @@ LL | struct 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:113:20
+ --> $DIR/empty-match.rs:123:20
|
LL | match_no_arms!(NonEmptyStruct2(true));
| ^^^^^^^^^^^^^^^^^^^^^
@@ -93,7 +93,7 @@ LL | struct NonEmptyStruct2(bool);
= 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:115:20
+ --> $DIR/empty-match.rs:125:20
|
LL | match_no_arms!((NonEmptyUnion1 { foo: () }));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -107,7 +107,7 @@ LL | union 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:117:20
+ --> $DIR/empty-match.rs:127:20
|
LL | match_no_arms!((NonEmptyUnion2 { foo: () }));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -121,42 +121,44 @@ LL | union 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:119:20
+ --> $DIR/empty-match.rs:129:20
|
LL | match_no_arms!(NonEmptyEnum1::Foo(true));
| ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyEnum1::Foo(_)` not covered
|
note: `NonEmptyEnum1` defined here
- --> $DIR/empty-match.rs:33:5
+ --> $DIR/empty-match.rs:32:6
|
LL | enum NonEmptyEnum1 {
- | -------------
+ | ^^^^^^^^^^^^^
+...
LL | Foo(bool),
- | ^^^ not covered
+ | --- 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:122:20
+ --> $DIR/empty-match.rs:132:20
|
LL | match_no_arms!(NonEmptyEnum2::Foo(true));
| ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
|
note: `NonEmptyEnum2` defined here
- --> $DIR/empty-match.rs:40:5
+ --> $DIR/empty-match.rs:39:6
|
LL | enum NonEmptyEnum2 {
- | -------------
+ | ^^^^^^^^^^^^^
+...
LL | Foo(bool),
- | ^^^ not covered
+ | --- not covered
...
LL | Bar,
- | ^^^ not covered
+ | --- 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:125:20
+ --> $DIR/empty-match.rs:135:20
|
LL | match_no_arms!(NonEmptyEnum5::V1);
| ^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
@@ -166,11 +168,19 @@ note: `NonEmptyEnum5` defined here
|
LL | enum NonEmptyEnum5 {
| ^^^^^^^^^^^^^
+...
+LL | V1, V2, V3, V4, V5,
+ | -- -- -- -- -- not covered
+ | | | | |
+ | | | | not covered
+ | | | not covered
+ | | not covered
+ | 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:129:24
+ --> $DIR/empty-match.rs:139:24
|
LL | match_guarded_arm!(0u8);
| ^^^ pattern `_` not covered
@@ -184,7 +194,7 @@ LL + _ => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyStruct1` not covered
- --> $DIR/empty-match.rs:134:24
+ --> $DIR/empty-match.rs:144:24
|
LL | match_guarded_arm!(NonEmptyStruct1);
| ^^^^^^^^^^^^^^^ pattern `NonEmptyStruct1` not covered
@@ -203,7 +213,7 @@ LL + NonEmptyStruct1 => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyStruct2(_)` not covered
- --> $DIR/empty-match.rs:139:24
+ --> $DIR/empty-match.rs:149:24
|
LL | match_guarded_arm!(NonEmptyStruct2(true));
| ^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyStruct2(_)` not covered
@@ -222,7 +232,7 @@ LL + NonEmptyStruct2(_) => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyUnion1 { .. }` not covered
- --> $DIR/empty-match.rs:144:24
+ --> $DIR/empty-match.rs:154:24
|
LL | match_guarded_arm!((NonEmptyUnion1 { foo: () }));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion1 { .. }` not covered
@@ -241,7 +251,7 @@ LL + NonEmptyUnion1 { .. } => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyUnion2 { .. }` not covered
- --> $DIR/empty-match.rs:149:24
+ --> $DIR/empty-match.rs:159:24
|
LL | match_guarded_arm!((NonEmptyUnion2 { foo: () }));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion2 { .. }` not covered
@@ -260,18 +270,19 @@ LL + NonEmptyUnion2 { .. } => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyEnum1::Foo(_)` not covered
- --> $DIR/empty-match.rs:154:24
+ --> $DIR/empty-match.rs:164:24
|
LL | match_guarded_arm!(NonEmptyEnum1::Foo(true));
| ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyEnum1::Foo(_)` not covered
|
note: `NonEmptyEnum1` defined here
- --> $DIR/empty-match.rs:33:5
+ --> $DIR/empty-match.rs:32:6
|
LL | enum NonEmptyEnum1 {
- | -------------
+ | ^^^^^^^^^^^^^
+...
LL | Foo(bool),
- | ^^^ not covered
+ | --- 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
@@ -281,21 +292,22 @@ LL + NonEmptyEnum1::Foo(_) => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
- --> $DIR/empty-match.rs:159:24
+ --> $DIR/empty-match.rs:169:24
|
LL | match_guarded_arm!(NonEmptyEnum2::Foo(true));
| ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
|
note: `NonEmptyEnum2` defined here
- --> $DIR/empty-match.rs:40:5
+ --> $DIR/empty-match.rs:39:6
|
LL | enum NonEmptyEnum2 {
- | -------------
+ | ^^^^^^^^^^^^^
+...
LL | Foo(bool),
- | ^^^ not covered
+ | --- not covered
...
LL | Bar,
- | ^^^ not covered
+ | --- 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
@@ -305,7 +317,7 @@ 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:164:24
+ --> $DIR/empty-match.rs:174:24
|
LL | match_guarded_arm!(NonEmptyEnum5::V1);
| ^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
@@ -315,6 +327,14 @@ note: `NonEmptyEnum5` defined here
|
LL | enum NonEmptyEnum5 {
| ^^^^^^^^^^^^^
+...
+LL | V1, V2, V3, V4, V5,
+ | -- -- -- -- -- not covered
+ | | | | |
+ | | | | not covered
+ | | | not covered
+ | | not covered
+ | 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
diff --git a/tests/ui/pattern/usefulness/empty-match.normal.stderr b/tests/ui/pattern/usefulness/empty-match.normal.stderr
index 6d1745508..7f0389f40 100644
--- a/tests/ui/pattern/usefulness/empty-match.normal.stderr
+++ b/tests/ui/pattern/usefulness/empty-match.normal.stderr
@@ -1,5 +1,5 @@
error: unreachable pattern
- --> $DIR/empty-match.rs:58:9
+ --> $DIR/empty-match.rs:68:9
|
LL | _ => {},
| ^
@@ -11,25 +11,25 @@ LL | #![deny(unreachable_patterns)]
| ^^^^^^^^^^^^^^^^^^^^
error: unreachable pattern
- --> $DIR/empty-match.rs:61:9
+ --> $DIR/empty-match.rs:71:9
|
LL | _ if false => {},
| ^
error: unreachable pattern
- --> $DIR/empty-match.rs:68:9
+ --> $DIR/empty-match.rs:78:9
|
LL | _ => {},
| ^
error: unreachable pattern
- --> $DIR/empty-match.rs:71:9
+ --> $DIR/empty-match.rs:81:9
|
LL | _ if false => {},
| ^
error[E0005]: refutable pattern in local binding
- --> $DIR/empty-match.rs:76:9
+ --> $DIR/empty-match.rs:86:9
|
LL | let None = x;
| ^^^^ pattern `Some(_)` not covered
@@ -43,19 +43,19 @@ LL | if let None = x { todo!() };
| ++ +++++++++++
error: unreachable pattern
- --> $DIR/empty-match.rs:88:9
+ --> $DIR/empty-match.rs:98:9
|
LL | _ => {},
| ^
error: unreachable pattern
- --> $DIR/empty-match.rs:91:9
+ --> $DIR/empty-match.rs:101:9
|
LL | _ if false => {},
| ^
error[E0004]: non-exhaustive patterns: type `u8` is non-empty
- --> $DIR/empty-match.rs:109:20
+ --> $DIR/empty-match.rs:119:20
|
LL | match_no_arms!(0u8);
| ^^^
@@ -64,7 +64,7 @@ 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:111:20
+ --> $DIR/empty-match.rs:121:20
|
LL | match_no_arms!(NonEmptyStruct1);
| ^^^^^^^^^^^^^^^
@@ -78,7 +78,7 @@ LL | struct 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:113:20
+ --> $DIR/empty-match.rs:123:20
|
LL | match_no_arms!(NonEmptyStruct2(true));
| ^^^^^^^^^^^^^^^^^^^^^
@@ -92,7 +92,7 @@ LL | struct NonEmptyStruct2(bool);
= 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:115:20
+ --> $DIR/empty-match.rs:125:20
|
LL | match_no_arms!((NonEmptyUnion1 { foo: () }));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -106,7 +106,7 @@ LL | union 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:117:20
+ --> $DIR/empty-match.rs:127:20
|
LL | match_no_arms!((NonEmptyUnion2 { foo: () }));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -120,42 +120,44 @@ LL | union 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:119:20
+ --> $DIR/empty-match.rs:129:20
|
LL | match_no_arms!(NonEmptyEnum1::Foo(true));
| ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyEnum1::Foo(_)` not covered
|
note: `NonEmptyEnum1` defined here
- --> $DIR/empty-match.rs:33:5
+ --> $DIR/empty-match.rs:32:6
|
LL | enum NonEmptyEnum1 {
- | -------------
+ | ^^^^^^^^^^^^^
+...
LL | Foo(bool),
- | ^^^ not covered
+ | --- 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:122:20
+ --> $DIR/empty-match.rs:132:20
|
LL | match_no_arms!(NonEmptyEnum2::Foo(true));
| ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
|
note: `NonEmptyEnum2` defined here
- --> $DIR/empty-match.rs:40:5
+ --> $DIR/empty-match.rs:39:6
|
LL | enum NonEmptyEnum2 {
- | -------------
+ | ^^^^^^^^^^^^^
+...
LL | Foo(bool),
- | ^^^ not covered
+ | --- not covered
...
LL | Bar,
- | ^^^ not covered
+ | --- 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:125:20
+ --> $DIR/empty-match.rs:135:20
|
LL | match_no_arms!(NonEmptyEnum5::V1);
| ^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
@@ -165,11 +167,19 @@ note: `NonEmptyEnum5` defined here
|
LL | enum NonEmptyEnum5 {
| ^^^^^^^^^^^^^
+...
+LL | V1, V2, V3, V4, V5,
+ | -- -- -- -- -- not covered
+ | | | | |
+ | | | | not covered
+ | | | not covered
+ | | not covered
+ | 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:129:24
+ --> $DIR/empty-match.rs:139:24
|
LL | match_guarded_arm!(0u8);
| ^^^ pattern `_` not covered
@@ -183,7 +193,7 @@ LL + _ => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyStruct1` not covered
- --> $DIR/empty-match.rs:134:24
+ --> $DIR/empty-match.rs:144:24
|
LL | match_guarded_arm!(NonEmptyStruct1);
| ^^^^^^^^^^^^^^^ pattern `NonEmptyStruct1` not covered
@@ -202,7 +212,7 @@ LL + NonEmptyStruct1 => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyStruct2(_)` not covered
- --> $DIR/empty-match.rs:139:24
+ --> $DIR/empty-match.rs:149:24
|
LL | match_guarded_arm!(NonEmptyStruct2(true));
| ^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyStruct2(_)` not covered
@@ -221,7 +231,7 @@ LL + NonEmptyStruct2(_) => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyUnion1 { .. }` not covered
- --> $DIR/empty-match.rs:144:24
+ --> $DIR/empty-match.rs:154:24
|
LL | match_guarded_arm!((NonEmptyUnion1 { foo: () }));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion1 { .. }` not covered
@@ -240,7 +250,7 @@ LL + NonEmptyUnion1 { .. } => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyUnion2 { .. }` not covered
- --> $DIR/empty-match.rs:149:24
+ --> $DIR/empty-match.rs:159:24
|
LL | match_guarded_arm!((NonEmptyUnion2 { foo: () }));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion2 { .. }` not covered
@@ -259,18 +269,19 @@ LL + NonEmptyUnion2 { .. } => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyEnum1::Foo(_)` not covered
- --> $DIR/empty-match.rs:154:24
+ --> $DIR/empty-match.rs:164:24
|
LL | match_guarded_arm!(NonEmptyEnum1::Foo(true));
| ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyEnum1::Foo(_)` not covered
|
note: `NonEmptyEnum1` defined here
- --> $DIR/empty-match.rs:33:5
+ --> $DIR/empty-match.rs:32:6
|
LL | enum NonEmptyEnum1 {
- | -------------
+ | ^^^^^^^^^^^^^
+...
LL | Foo(bool),
- | ^^^ not covered
+ | --- 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
@@ -280,21 +291,22 @@ LL + NonEmptyEnum1::Foo(_) => todo!()
|
error[E0004]: non-exhaustive patterns: `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
- --> $DIR/empty-match.rs:159:24
+ --> $DIR/empty-match.rs:169:24
|
LL | match_guarded_arm!(NonEmptyEnum2::Foo(true));
| ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered
|
note: `NonEmptyEnum2` defined here
- --> $DIR/empty-match.rs:40:5
+ --> $DIR/empty-match.rs:39:6
|
LL | enum NonEmptyEnum2 {
- | -------------
+ | ^^^^^^^^^^^^^
+...
LL | Foo(bool),
- | ^^^ not covered
+ | --- not covered
...
LL | Bar,
- | ^^^ not covered
+ | --- 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
@@ -304,7 +316,7 @@ 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:164:24
+ --> $DIR/empty-match.rs:174:24
|
LL | match_guarded_arm!(NonEmptyEnum5::V1);
| ^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered
@@ -314,6 +326,14 @@ note: `NonEmptyEnum5` defined here
|
LL | enum NonEmptyEnum5 {
| ^^^^^^^^^^^^^
+...
+LL | V1, V2, V3, V4, V5,
+ | -- -- -- -- -- not covered
+ | | | | |
+ | | | | not covered
+ | | | not covered
+ | | not covered
+ | 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
diff --git a/tests/ui/pattern/usefulness/empty-match.rs b/tests/ui/pattern/usefulness/empty-match.rs
index d56d2e3c8..fe5d0bce1 100644
--- a/tests/ui/pattern/usefulness/empty-match.rs
+++ b/tests/ui/pattern/usefulness/empty-match.rs
@@ -30,17 +30,17 @@ union NonEmptyUnion2 {
bar: (),
}
enum NonEmptyEnum1 {
- Foo(bool),
//~^ NOTE `NonEmptyEnum1` defined here
//~| NOTE `NonEmptyEnum1` defined here
- //~| NOTE not covered
+ Foo(bool),
+ //~^ NOTE not covered
//~| NOTE not covered
}
enum NonEmptyEnum2 {
- Foo(bool),
//~^ NOTE `NonEmptyEnum2` defined here
//~| NOTE `NonEmptyEnum2` defined here
- //~| NOTE not covered
+ Foo(bool),
+ //~^ NOTE not covered
//~| NOTE not covered
Bar,
//~^ NOTE not covered
@@ -50,6 +50,16 @@ 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) {
diff --git a/tests/ui/pattern/usefulness/floats.rs b/tests/ui/pattern/usefulness/floats.rs
index 095f5ac9a..2616dfadb 100644
--- a/tests/ui/pattern/usefulness/floats.rs
+++ b/tests/ui/pattern/usefulness/floats.rs
@@ -1,19 +1,45 @@
+#![feature(exclusive_range_pattern)]
#![allow(illegal_floating_point_literal_pattern)]
#![deny(unreachable_patterns)]
fn main() {
match 0.0 {
- 0.0..=1.0 => {}
- _ => {} // ok
+ 0.0..=1.0 => {}
+ _ => {} // ok
}
- match 0.0 { //~ ERROR non-exhaustive patterns
- 0.0..=1.0 => {}
+ match 0.0 {
+ //~^ ERROR non-exhaustive patterns
+ 0.0..=1.0 => {}
}
match 1.0f64 {
- 0.01f64 ..= 6.5f64 => {}
- 0.02f64 => {} //~ ERROR unreachable pattern
- _ => {}
+ 0.01f64..=6.5f64 => {}
+ 0.005f64 => {}
+ 0.01f64 => {} //~ ERROR unreachable pattern
+ 0.02f64 => {} //~ ERROR unreachable pattern
+ 6.5f64 => {} //~ ERROR unreachable pattern
+ 6.6f64 => {}
+ 1.0f64..=4.0f64 => {} //~ ERROR unreachable pattern
+ 5.0f64..=7.0f64 => {}
+ _ => {}
+ };
+ match 1.0f64 {
+ 0.01f64..6.5f64 => {}
+ 6.5f64 => {} // this is reachable
+ _ => {}
+ };
+
+ match 1.0f32 {
+ 0.01f32..=6.5f32 => {}
+ 0.01f32 => {} //~ ERROR unreachable pattern
+ 0.02f32 => {} //~ ERROR unreachable pattern
+ 6.5f32 => {} //~ ERROR unreachable pattern
+ _ => {}
+ };
+ match 1.0f32 {
+ 0.01f32..6.5f32 => {}
+ 6.5f32 => {} // this is reachable
+ _ => {}
};
}
diff --git a/tests/ui/pattern/usefulness/floats.stderr b/tests/ui/pattern/usefulness/floats.stderr
index d66d4ba29..f50419118 100644
--- a/tests/ui/pattern/usefulness/floats.stderr
+++ b/tests/ui/pattern/usefulness/floats.stderr
@@ -1,5 +1,5 @@
error[E0004]: non-exhaustive patterns: `_` not covered
- --> $DIR/floats.rs:10:11
+ --> $DIR/floats.rs:11:11
|
LL | match 0.0 {
| ^^^ pattern `_` not covered
@@ -7,22 +7,58 @@ LL | match 0.0 {
= note: the matched value is of type `f64`
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.0..=1.0 => {},
-LL + _ => todo!()
+LL ~ 0.0..=1.0 => {},
+LL + _ => todo!()
|
error: unreachable pattern
- --> $DIR/floats.rs:16:7
+ --> $DIR/floats.rs:19:9
|
-LL | 0.02f64 => {}
- | ^^^^^^^
+LL | 0.01f64 => {}
+ | ^^^^^^^
|
note: the lint level is defined here
- --> $DIR/floats.rs:2:9
+ --> $DIR/floats.rs:3:9
|
LL | #![deny(unreachable_patterns)]
| ^^^^^^^^^^^^^^^^^^^^
-error: aborting due to 2 previous errors
+error: unreachable pattern
+ --> $DIR/floats.rs:20:9
+ |
+LL | 0.02f64 => {}
+ | ^^^^^^^
+
+error: unreachable pattern
+ --> $DIR/floats.rs:21:9
+ |
+LL | 6.5f64 => {}
+ | ^^^^^^
+
+error: unreachable pattern
+ --> $DIR/floats.rs:23:9
+ |
+LL | 1.0f64..=4.0f64 => {}
+ | ^^^^^^^^^^^^^^^
+
+error: unreachable pattern
+ --> $DIR/floats.rs:35:9
+ |
+LL | 0.01f32 => {}
+ | ^^^^^^^
+
+error: unreachable pattern
+ --> $DIR/floats.rs:36:9
+ |
+LL | 0.02f32 => {}
+ | ^^^^^^^
+
+error: unreachable pattern
+ --> $DIR/floats.rs:37:9
+ |
+LL | 6.5f32 => {}
+ | ^^^^^^
+
+error: aborting due to 8 previous errors
For more information about this error, try `rustc --explain E0004`.
diff --git a/tests/ui/pattern/usefulness/integer-ranges/overlapping_range_endpoints.rs b/tests/ui/pattern/usefulness/integer-ranges/overlapping_range_endpoints.rs
index 5ea92b070..33c1dfd39 100644
--- a/tests/ui/pattern/usefulness/integer-ranges/overlapping_range_endpoints.rs
+++ b/tests/ui/pattern/usefulness/integer-ranges/overlapping_range_endpoints.rs
@@ -8,7 +8,7 @@ macro_rules! m {
$t2 => {}
_ => {}
}
- }
+ };
}
fn main() {
@@ -16,9 +16,9 @@ fn main() {
m!(0u8, 30..=40, 20..=30); //~ ERROR multiple patterns overlap on their endpoints
m!(0u8, 20..=30, 31..=40);
m!(0u8, 20..=30, 29..=40);
- m!(0u8, 20.. 30, 29..=40); //~ ERROR multiple patterns overlap on their endpoints
- m!(0u8, 20.. 30, 28..=40);
- m!(0u8, 20.. 30, 30..=40);
+ m!(0u8, 20..30, 29..=40); //~ ERROR multiple patterns overlap on their endpoints
+ m!(0u8, 20..30, 28..=40);
+ m!(0u8, 20..30, 30..=40);
m!(0u8, 20..=30, 30..=30);
m!(0u8, 20..=30, 30..=31); //~ ERROR multiple patterns overlap on their endpoints
m!(0u8, 20..=30, 29..=30);
@@ -28,7 +28,7 @@ fn main() {
m!(0u8, 20..=30, 20);
m!(0u8, 20..=30, 25);
m!(0u8, 20..=30, 30);
- m!(0u8, 20.. 30, 29);
+ m!(0u8, 20..30, 29);
m!(0u8, 20, 20..=30);
m!(0u8, 25, 20..=30);
m!(0u8, 30, 20..=30);
@@ -36,19 +36,21 @@ fn main() {
match 0u8 {
0..=10 => {}
20..=30 => {}
- 10..=20 => {} //~ ERROR multiple patterns overlap on their endpoints
+ 10..=20 => {}
+ //~^ ERROR multiple patterns overlap on their endpoints
+ //~| ERROR multiple patterns overlap on their endpoints
_ => {}
}
match (0u8, true) {
(0..=10, true) => {}
- (10..20, true) => {} // not detected
- (10..20, false) => {}
+ (10..20, true) => {} //~ ERROR multiple patterns overlap on their endpoints
+ (10..20, false) => {} //~ ERROR multiple patterns overlap on their endpoints
_ => {}
}
match (true, 0u8) {
(true, 0..=10) => {}
(true, 10..20) => {} //~ ERROR multiple patterns overlap on their endpoints
- (false, 10..20) => {}
+ (false, 10..20) => {} //~ ERROR multiple patterns overlap on their endpoints
_ => {}
}
match Some(0u8) {
diff --git a/tests/ui/pattern/usefulness/integer-ranges/overlapping_range_endpoints.stderr b/tests/ui/pattern/usefulness/integer-ranges/overlapping_range_endpoints.stderr
index ea0e8f6e4..a87205d76 100644
--- a/tests/ui/pattern/usefulness/integer-ranges/overlapping_range_endpoints.stderr
+++ b/tests/ui/pattern/usefulness/integer-ranges/overlapping_range_endpoints.stderr
@@ -24,10 +24,10 @@ LL | m!(0u8, 30..=40, 20..=30);
= note: you likely meant to write mutually exclusive ranges
error: multiple patterns overlap on their endpoints
- --> $DIR/overlapping_range_endpoints.rs:19:22
+ --> $DIR/overlapping_range_endpoints.rs:19:21
|
-LL | m!(0u8, 20.. 30, 29..=40);
- | ------- ^^^^^^^ ... with this range
+LL | m!(0u8, 20..30, 29..=40);
+ | ------ ^^^^^^^ ... with this range
| |
| this range overlaps on `29_u8`...
|
@@ -59,6 +59,15 @@ error: multiple patterns overlap on their endpoints
LL | 0..=10 => {}
| ------ this range overlaps on `10_u8`...
LL | 20..=30 => {}
+LL | 10..=20 => {}
+ | ^^^^^^^ ... with this range
+ |
+ = note: you likely meant to write mutually exclusive ranges
+
+error: multiple patterns overlap on their endpoints
+ --> $DIR/overlapping_range_endpoints.rs:39:9
+ |
+LL | 20..=30 => {}
| ------- this range overlaps on `20_u8`...
LL | 10..=20 => {}
| ^^^^^^^ ... with this range
@@ -66,7 +75,28 @@ LL | 10..=20 => {}
= note: you likely meant to write mutually exclusive ranges
error: multiple patterns overlap on their endpoints
- --> $DIR/overlapping_range_endpoints.rs:50:16
+ --> $DIR/overlapping_range_endpoints.rs:46:10
+ |
+LL | (0..=10, true) => {}
+ | ------ this range overlaps on `10_u8`...
+LL | (10..20, true) => {}
+ | ^^^^^^ ... with this range
+ |
+ = note: you likely meant to write mutually exclusive ranges
+
+error: multiple patterns overlap on their endpoints
+ --> $DIR/overlapping_range_endpoints.rs:47:10
+ |
+LL | (0..=10, true) => {}
+ | ------ this range overlaps on `10_u8`...
+LL | (10..20, true) => {}
+LL | (10..20, false) => {}
+ | ^^^^^^ ... with this range
+ |
+ = note: you likely meant to write mutually exclusive ranges
+
+error: multiple patterns overlap on their endpoints
+ --> $DIR/overlapping_range_endpoints.rs:52:16
|
LL | (true, 0..=10) => {}
| ------ this range overlaps on `10_u8`...
@@ -76,7 +106,18 @@ LL | (true, 10..20) => {}
= note: you likely meant to write mutually exclusive ranges
error: multiple patterns overlap on their endpoints
- --> $DIR/overlapping_range_endpoints.rs:56:14
+ --> $DIR/overlapping_range_endpoints.rs:53:17
+ |
+LL | (true, 0..=10) => {}
+ | ------ this range overlaps on `10_u8`...
+LL | (true, 10..20) => {}
+LL | (false, 10..20) => {}
+ | ^^^^^^ ... with this range
+ |
+ = note: you likely meant to write mutually exclusive ranges
+
+error: multiple patterns overlap on their endpoints
+ --> $DIR/overlapping_range_endpoints.rs:58:14
|
LL | Some(0..=10) => {}
| ------ this range overlaps on `10_u8`...
@@ -85,5 +126,5 @@ LL | Some(10..20) => {}
|
= note: you likely meant to write mutually exclusive ranges
-error: aborting due to 8 previous errors
+error: aborting due to 12 previous errors
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
index 9f277fa1e..7f26c93aa 100644
--- a/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.allow.stderr
+++ b/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.allow.stderr
@@ -1,5 +1,5 @@
error[E0004]: non-exhaustive patterns: type `usize` is non-empty
- --> $DIR/pointer-sized-int.rs:48:11
+ --> $DIR/pointer-sized-int.rs:54:11
|
LL | match 7usize {}
| ^^^^^^
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 df330c60b..d16ec5412 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,162 @@
-error[E0004]: non-exhaustive patterns: `_` not covered
- --> $DIR/pointer-sized-int.rs:12:11
+error[E0004]: non-exhaustive patterns: `usize::MAX..` not covered
+ --> $DIR/pointer-sized-int.rs:14:11
|
LL | match 0usize {
- | ^^^^^^ pattern `_` not covered
+ | ^^^^^^ pattern `usize::MAX..` not covered
|
= note: the matched value is of type `usize`
- = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively
+ = 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 + _ => todo!()
+LL + usize::MAX.. => todo!()
|
-error[E0004]: non-exhaustive patterns: `_` not covered
- --> $DIR/pointer-sized-int.rs:17:11
+error[E0004]: non-exhaustive patterns: `..isize::MIN` and `isize::MAX..` not covered
+ --> $DIR/pointer-sized-int.rs:19:11
|
LL | match 0isize {
- | ^^^^^^ pattern `_` not covered
+ | ^^^^^^ patterns `..isize::MIN` and `isize::MAX..` not covered
|
= note: the matched value is of type `isize`
- = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively
+ = 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 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 ~ isize::MIN ..= isize::MAX => {},
-LL + _ => todo!()
+LL + ..isize::MIN | isize::MAX.. => todo!()
|
-error[E0004]: non-exhaustive patterns: `_` not covered
- --> $DIR/pointer-sized-int.rs:22:8
+error[E0004]: non-exhaustive patterns: `usize::MAX..` not covered
+ --> $DIR/pointer-sized-int.rs:25:8
|
LL | m!(0usize, 0..=usize::MAX);
- | ^^^^^^ pattern `_` not covered
+ | ^^^^^^ pattern `usize::MAX..` not covered
|
= note: the matched value is of type `usize`
- = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively
+ = 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)+ => {}, _ => todo!() }
- | ++++++++++++++
+LL | match $s { $($t)+ => {}, usize::MAX.. => todo!() }
+ | +++++++++++++++++++++++++
-error[E0004]: non-exhaustive patterns: `_` not covered
- --> $DIR/pointer-sized-int.rs:24:8
+error[E0004]: non-exhaustive patterns: `usize::MAX..` not covered
+ --> $DIR/pointer-sized-int.rs:27:8
|
LL | m!(0usize, 0..5 | 5..=usize::MAX);
- | ^^^^^^ pattern `_` not covered
+ | ^^^^^^ pattern `usize::MAX..` not covered
|
= note: the matched value is of type `usize`
- = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively
+ = 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)+ => {}, _ => todo!() }
- | ++++++++++++++
+LL | match $s { $($t)+ => {}, usize::MAX.. => todo!() }
+ | +++++++++++++++++++++++++
-error[E0004]: non-exhaustive patterns: `_` not covered
- --> $DIR/pointer-sized-int.rs:26:8
+error[E0004]: non-exhaustive patterns: `usize::MAX..` not covered
+ --> $DIR/pointer-sized-int.rs:29:8
|
LL | m!(0usize, 0..usize::MAX | usize::MAX);
- | ^^^^^^ pattern `_` not covered
+ | ^^^^^^ pattern `usize::MAX..` not covered
|
= note: the matched value is of type `usize`
- = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively
+ = 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)+ => {}, _ => todo!() }
- | ++++++++++++++
+LL | match $s { $($t)+ => {}, usize::MAX.. => todo!() }
+ | +++++++++++++++++++++++++
-error[E0004]: non-exhaustive patterns: `(_, _)` not covered
- --> $DIR/pointer-sized-int.rs:28:8
+error[E0004]: non-exhaustive patterns: `(usize::MAX.., _)` not covered
+ --> $DIR/pointer-sized-int.rs:31:8
|
LL | m!((0usize, true), (0..5, true) | (5..=usize::MAX, true) | (0..=usize::MAX, false));
- | ^^^^^^^^^^^^^^ pattern `(_, _)` not covered
+ | ^^^^^^^^^^^^^^ pattern `(usize::MAX.., _)` not covered
|
= note: the matched value is of type `(usize, bool)`
- = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively
+ = 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)+ => {}, (_, _) => todo!() }
- | +++++++++++++++++++
+LL | match $s { $($t)+ => {}, (usize::MAX.., _) => todo!() }
+ | ++++++++++++++++++++++++++++++
-error[E0004]: non-exhaustive patterns: `_` not covered
- --> $DIR/pointer-sized-int.rs:31:8
+error[E0004]: non-exhaustive patterns: `..isize::MIN` and `isize::MAX..` not covered
+ --> $DIR/pointer-sized-int.rs:36:8
|
LL | m!(0isize, isize::MIN..=isize::MAX);
- | ^^^^^^ pattern `_` not covered
+ | ^^^^^^ patterns `..isize::MIN` and `isize::MAX..` not covered
|
= note: the matched value is of type `isize`
- = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively
+ = 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 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 $s { $($t)+ => {}, _ => todo!() }
- | ++++++++++++++
+LL | match $s { $($t)+ => {}, ..isize::MIN | isize::MAX.. => todo!() }
+ | ++++++++++++++++++++++++++++++++++++++++
-error[E0004]: non-exhaustive patterns: `_` not covered
- --> $DIR/pointer-sized-int.rs:33:8
+error[E0004]: non-exhaustive patterns: `..isize::MIN` and `isize::MAX..` not covered
+ --> $DIR/pointer-sized-int.rs:38:8
|
LL | m!(0isize, isize::MIN..5 | 5..=isize::MAX);
- | ^^^^^^ pattern `_` not covered
+ | ^^^^^^ patterns `..isize::MIN` and `isize::MAX..` not covered
|
= note: the matched value is of type `isize`
- = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively
+ = 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 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 $s { $($t)+ => {}, _ => todo!() }
- | ++++++++++++++
+LL | match $s { $($t)+ => {}, ..isize::MIN | isize::MAX.. => todo!() }
+ | ++++++++++++++++++++++++++++++++++++++++
-error[E0004]: non-exhaustive patterns: `_` not covered
- --> $DIR/pointer-sized-int.rs:35:8
+error[E0004]: non-exhaustive patterns: `..isize::MIN` and `isize::MAX..` not covered
+ --> $DIR/pointer-sized-int.rs:40:8
|
LL | m!(0isize, isize::MIN..isize::MAX | isize::MAX);
- | ^^^^^^ pattern `_` not covered
+ | ^^^^^^ patterns `..isize::MIN` and `isize::MAX..` not covered
|
= note: the matched value is of type `isize`
- = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively
+ = 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 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 $s { $($t)+ => {}, _ => todo!() }
- | ++++++++++++++
+LL | match $s { $($t)+ => {}, ..isize::MIN | isize::MAX.. => todo!() }
+ | ++++++++++++++++++++++++++++++++++++++++
-error[E0004]: non-exhaustive patterns: `(_, _)` not covered
- --> $DIR/pointer-sized-int.rs:37:8
+error[E0004]: non-exhaustive patterns: `(..isize::MIN, _)` and `(isize::MAX.., _)` not covered
+ --> $DIR/pointer-sized-int.rs:42:8
|
LL | m!((0isize, true), (isize::MIN..5, true)
- | ^^^^^^^^^^^^^^ pattern `(_, _)` not covered
+ | ^^^^^^^^^^^^^^ patterns `(..isize::MIN, _)` and `(isize::MAX.., _)` not covered
|
= note: the matched value is of type `(isize, bool)`
- = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively
+ = 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 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 $s { $($t)+ => {}, (_, _) => todo!() }
- | +++++++++++++++++++
+LL | match $s { $($t)+ => {}, (..isize::MIN, _) | (isize::MAX.., _) => todo!() }
+ | ++++++++++++++++++++++++++++++++++++++++++++++++++
-error[E0004]: non-exhaustive patterns: `_` not covered
- --> $DIR/pointer-sized-int.rs:41:11
+error[E0004]: non-exhaustive patterns: `..isize::MIN` and `isize::MAX..` not covered
+ --> $DIR/pointer-sized-int.rs:47:11
|
LL | match 0isize {
- | ^^^^^^ pattern `_` not covered
+ | ^^^^^^ patterns `..isize::MIN` and `isize::MAX..` not covered
|
= note: the matched value is of type `isize`
- = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively
+ = 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 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 ~ 1 ..= isize::MAX => {},
-LL + _ => todo!()
+LL + ..isize::MIN | isize::MAX.. => todo!()
|
error[E0004]: non-exhaustive patterns: type `usize` is non-empty
- --> $DIR/pointer-sized-int.rs:48:11
+ --> $DIR/pointer-sized-int.rs:54: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 1ed18c267..20a3cbe12 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,7 @@
// revisions: allow deny
#![feature(exclusive_range_pattern)]
#![cfg_attr(allow, feature(precise_pointer_size_matching))]
+#![allow(overlapping_range_endpoints)]
macro_rules! m {
($s:expr, $($t:tt)+) => {
@@ -8,6 +9,7 @@ macro_rules! m {
}
}
+#[rustfmt::skip]
fn main() {
match 0usize {
//[deny]~^ ERROR non-exhaustive patterns
@@ -19,6 +21,7 @@ fn main() {
isize::MIN ..= isize::MAX => {}
}
+ m!(0usize, 0..);
m!(0usize, 0..=usize::MAX);
//[deny]~^ ERROR non-exhaustive patterns
m!(0usize, 0..5 | 5..=usize::MAX);
@@ -27,7 +30,9 @@ fn main() {
//[deny]~^ ERROR non-exhaustive patterns
m!((0usize, true), (0..5, true) | (5..=usize::MAX, true) | (0..=usize::MAX, false));
//[deny]~^ ERROR non-exhaustive patterns
+ m!(0usize, 0..=usize::MAX | usize::MAX..);
+ m!(0isize, ..0 | 0..);
m!(0isize, isize::MIN..=isize::MAX);
//[deny]~^ ERROR non-exhaustive patterns
m!(0isize, isize::MIN..5 | 5..=isize::MAX);
@@ -37,6 +42,7 @@ fn main() {
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..);
match 0isize {
//[deny]~^ ERROR non-exhaustive patterns
diff --git a/tests/ui/pattern/usefulness/integer-ranges/precise_pointer_matching-message.rs b/tests/ui/pattern/usefulness/integer-ranges/precise_pointer_matching-message.rs
index a2aa655ca..d60f479c0 100644
--- a/tests/ui/pattern/usefulness/integer-ranges/precise_pointer_matching-message.rs
+++ b/tests/ui/pattern/usefulness/integer-ranges/precise_pointer_matching-message.rs
@@ -1,18 +1,18 @@
// This tests that the lint message explains the reason for the error.
fn main() {
match 0usize {
- //~^ ERROR non-exhaustive patterns: `_` not covered
- //~| NOTE pattern `_` not covered
+ //~^ ERROR non-exhaustive patterns: `usize::MAX..` not covered
+ //~| NOTE pattern `usize::MAX..` not covered
//~| NOTE the matched value is of type `usize`
//~| NOTE `usize` does not have a fixed maximum value
0..=usize::MAX => {}
}
match 0isize {
- //~^ ERROR non-exhaustive patterns: `_` not covered
- //~| NOTE pattern `_` not covered
+ //~^ ERROR non-exhaustive patterns: `..isize::MIN` and `isize::MAX..` not covered
+ //~| NOTE patterns `..isize::MIN` and `isize::MAX..` not covered
//~| NOTE the matched value is of type `isize`
- //~| NOTE `isize` does not have a fixed maximum value
+ //~| NOTE `isize` does not have fixed minimum and maximum values
isize::MIN..=isize::MAX => {}
}
}
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 b80411b26..a7f93648e 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
@@ -1,31 +1,31 @@
-error[E0004]: non-exhaustive patterns: `_` not covered
+error[E0004]: non-exhaustive patterns: `usize::MAX..` not covered
--> $DIR/precise_pointer_matching-message.rs:3:11
|
LL | match 0usize {
- | ^^^^^^ pattern `_` not covered
+ | ^^^^^^ pattern `usize::MAX..` not covered
|
= note: the matched value is of type `usize`
- = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively
+ = 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 + _ => todo!()
+LL + usize::MAX.. => todo!()
|
-error[E0004]: non-exhaustive patterns: `_` not covered
+error[E0004]: non-exhaustive patterns: `..isize::MIN` and `isize::MAX..` not covered
--> $DIR/precise_pointer_matching-message.rs:11:11
|
LL | match 0isize {
- | ^^^^^^ pattern `_` not covered
+ | ^^^^^^ patterns `..isize::MIN` and `isize::MAX..` not covered
|
= note: the matched value is of type `isize`
- = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively
+ = 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 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 ~ isize::MIN..=isize::MAX => {},
-LL + _ => todo!()
+LL + ..isize::MIN | isize::MAX.. => todo!()
|
error: aborting due to 2 previous errors
diff --git a/tests/ui/pattern/usefulness/issue-35609.stderr b/tests/ui/pattern/usefulness/issue-35609.stderr
index 6d5e2f410..9feedfde4 100644
--- a/tests/ui/pattern/usefulness/issue-35609.stderr
+++ b/tests/ui/pattern/usefulness/issue-35609.stderr
@@ -107,6 +107,9 @@ LL | match Some(A) {
|
note: `Option<Enum>` 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<Enum>`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms
|
diff --git a/tests/ui/pattern/usefulness/issue-39362.stderr b/tests/ui/pattern/usefulness/issue-39362.stderr
index b8b17918a..8dc534916 100644
--- a/tests/ui/pattern/usefulness/issue-39362.stderr
+++ b/tests/ui/pattern/usefulness/issue-39362.stderr
@@ -5,12 +5,12 @@ LL | match f {
| ^ patterns `Foo::Bar { bar: Bar::C, .. }`, `Foo::Bar { bar: Bar::D, .. }`, `Foo::Bar { bar: Bar::E, .. }` and 1 more not covered
|
note: `Foo` defined here
- --> $DIR/issue-39362.rs:2:5
+ --> $DIR/issue-39362.rs:1:6
|
LL | enum Foo {
- | ---
+ | ^^^
LL | Bar { bar: Bar, id: usize }
- | ^^^ not covered
+ | --- not covered
= note: the matched value is of type `Foo`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms
|
diff --git a/tests/ui/pattern/usefulness/issue-40221.stderr b/tests/ui/pattern/usefulness/issue-40221.stderr
index 4973e42b0..40b42af26 100644
--- a/tests/ui/pattern/usefulness/issue-40221.stderr
+++ b/tests/ui/pattern/usefulness/issue-40221.stderr
@@ -5,12 +5,12 @@ LL | match proto {
| ^^^^^ pattern `P::C(PC::QA)` not covered
|
note: `P` defined here
- --> $DIR/issue-40221.rs:2:5
+ --> $DIR/issue-40221.rs:1:6
|
LL | enum P {
- | -
+ | ^
LL | C(PC),
- | ^ not covered
+ | - not covered
= note: the matched value is of type `P`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
diff --git a/tests/ui/pattern/usefulness/issue-56379.stderr b/tests/ui/pattern/usefulness/issue-56379.stderr
index b3e40b992..50e13bdfd 100644
--- a/tests/ui/pattern/usefulness/issue-56379.stderr
+++ b/tests/ui/pattern/usefulness/issue-56379.stderr
@@ -5,16 +5,16 @@ LL | match Foo::A(true) {
| ^^^^^^^^^^^^ patterns `Foo::A(false)`, `Foo::B(false)` and `Foo::C(false)` not covered
|
note: `Foo` defined here
- --> $DIR/issue-56379.rs:2:5
+ --> $DIR/issue-56379.rs:1:6
|
LL | enum Foo {
- | ---
+ | ^^^
LL | A(bool),
- | ^ not covered
+ | - not covered
LL | B(bool),
- | ^ not covered
+ | - not covered
LL | C(bool),
- | ^ not covered
+ | - not covered
= note: the matched value is of type `Foo`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
|
diff --git a/tests/ui/pattern/usefulness/issue-85222-types-containing-non-exhaustive-types.rs b/tests/ui/pattern/usefulness/issue-85222-types-containing-non-exhaustive-types.rs
index 8f58227ee..6cbcfed70 100644
--- a/tests/ui/pattern/usefulness/issue-85222-types-containing-non-exhaustive-types.rs
+++ b/tests/ui/pattern/usefulness/issue-85222-types-containing-non-exhaustive-types.rs
@@ -6,19 +6,19 @@ struct B<T, U>(T, U);
fn main() {
match 0 {
- //~^ ERROR non-exhaustive patterns: `_` not covered [E0004]
+ //~^ ERROR non-exhaustive patterns: `usize::MAX..` not covered [E0004]
0 => (),
1..=usize::MAX => (),
}
match (0usize, 0usize) {
- //~^ ERROR non-exhaustive patterns: `(_, _)` not covered [E0004]
+ //~^ ERROR non-exhaustive patterns: `(usize::MAX.., _)` not covered [E0004]
(0, 0) => (),
(1..=usize::MAX, 1..=usize::MAX) => (),
}
match (0isize, 0usize) {
- //~^ ERROR non-exhaustive patterns: `(_, _)` not covered [E0004]
+ //~^ ERROR non-exhaustive patterns: `(..isize::MIN, _)` and `(isize::MAX.., _)` not covered [E0004]
(isize::MIN..=isize::MAX, 0) => (),
(isize::MIN..=isize::MAX, 1..=usize::MAX) => (),
}
@@ -30,14 +30,14 @@ fn main() {
}
match Some(4) {
- //~^ ERROR non-exhaustive patterns: `Some(_)` not covered
+ //~^ ERROR non-exhaustive patterns: `Some(usize::MAX..)` not covered
Some(0) => (),
Some(1..=usize::MAX) => (),
None => (),
}
match Some(Some(Some(0))) {
- //~^ ERROR non-exhaustive patterns: `Some(Some(Some(_)))` not covered
+ //~^ ERROR non-exhaustive patterns: `Some(Some(Some(usize::MAX..)))` not covered
Some(Some(Some(0))) => (),
Some(Some(Some(1..=usize::MAX))) => (),
Some(Some(None)) => (),
@@ -46,13 +46,13 @@ fn main() {
}
match (A { a: 0usize }) {
- //~^ ERROR non-exhaustive patterns: `A { .. }` not covered [E0004]
+ //~^ ERROR non-exhaustive patterns: `A { a: usize::MAX.. }` not covered [E0004]
A { a: 0 } => (),
A { a: 1..=usize::MAX } => (),
}
match B(0isize, 0usize) {
- //~^ ERROR non-exhaustive patterns: `B(_, _)` not covered [E0004]
+ //~^ ERROR non-exhaustive patterns: `B(..isize::MIN, _)` and `B(isize::MAX.., _)` not covered [E0004]
B(isize::MIN..=isize::MAX, 0) => (),
B(isize::MIN..=isize::MAX, 1..=usize::MAX) => (),
}
@@ -60,7 +60,7 @@ fn main() {
// Should report only the note about usize not having fixed max value and not report
// report the note about isize
match B(0isize, 0usize) {
- //~^ ERROR non-exhaustive patterns: `B(_, _)` not covered [E0004]
+ //~^ ERROR non-exhaustive patterns: `B(_, usize::MAX..)` not covered [E0004]
B(_, 0) => (),
B(_, 1..=usize::MAX) => (),
}
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 ea1d99e20..556efcda5 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
@@ -1,46 +1,46 @@
-error[E0004]: non-exhaustive patterns: `_` not covered
+error[E0004]: non-exhaustive patterns: `usize::MAX..` not covered
--> $DIR/issue-85222-types-containing-non-exhaustive-types.rs:8:11
|
LL | match 0 {
- | ^ pattern `_` not covered
+ | ^ pattern `usize::MAX..` not covered
|
= note: the matched value is of type `usize`
- = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively
+ = 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 => (),
-LL ~ _ => todo!(),
+LL ~ usize::MAX.. => todo!(),
|
-error[E0004]: non-exhaustive patterns: `(_, _)` not covered
+error[E0004]: non-exhaustive patterns: `(usize::MAX.., _)` not covered
--> $DIR/issue-85222-types-containing-non-exhaustive-types.rs:14:11
|
LL | match (0usize, 0usize) {
- | ^^^^^^^^^^^^^^^^ pattern `(_, _)` not covered
+ | ^^^^^^^^^^^^^^^^ pattern `(usize::MAX.., _)` not covered
|
= note: the matched value is of type `(usize, usize)`
- = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively
+ = 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) => (),
-LL ~ (_, _) => todo!(),
+LL ~ (usize::MAX.., _) => todo!(),
|
-error[E0004]: non-exhaustive patterns: `(_, _)` not covered
+error[E0004]: non-exhaustive patterns: `(..isize::MIN, _)` and `(isize::MAX.., _)` not covered
--> $DIR/issue-85222-types-containing-non-exhaustive-types.rs:20:11
|
LL | match (0isize, 0usize) {
- | ^^^^^^^^^^^^^^^^ pattern `(_, _)` not covered
+ | ^^^^^^^^^^^^^^^^ patterns `(..isize::MIN, _)` and `(isize::MAX.., _)` not covered
|
= note: the matched value is of type `(isize, usize)`
- = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively
+ = 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 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 ~ (isize::MIN..=isize::MAX, 1..=usize::MAX) => (),
-LL ~ (_, _) => todo!(),
+LL ~ (..isize::MIN, _) | (isize::MAX.., _) => todo!(),
|
error[E0004]: non-exhaustive patterns: `Some(_)` not covered
@@ -61,11 +61,11 @@ LL ~ None => {},
LL + Some(_) => todo!()
|
-error[E0004]: non-exhaustive patterns: `Some(_)` not covered
+error[E0004]: non-exhaustive patterns: `Some(usize::MAX..)` not covered
--> $DIR/issue-85222-types-containing-non-exhaustive-types.rs:32:11
|
LL | match Some(4) {
- | ^^^^^^^ pattern `Some(_)` not covered
+ | ^^^^^^^ pattern `Some(usize::MAX..)` not covered
|
note: `Option<usize>` defined here
--> $SRC_DIR/core/src/option.rs:LL:COL
@@ -73,19 +73,19 @@ 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 a wildcard `_` is necessary to match exhaustively
+ = 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 => (),
-LL ~ Some(_) => todo!(),
+LL ~ Some(usize::MAX..) => todo!(),
|
-error[E0004]: non-exhaustive patterns: `Some(Some(Some(_)))` not covered
+error[E0004]: non-exhaustive patterns: `Some(Some(Some(usize::MAX..)))` not covered
--> $DIR/issue-85222-types-containing-non-exhaustive-types.rs:39:11
|
LL | match Some(Some(Some(0))) {
- | ^^^^^^^^^^^^^^^^^^^ pattern `Some(Some(Some(_)))` not covered
+ | ^^^^^^^^^^^^^^^^^^^ pattern `Some(Some(Some(usize::MAX..)))` not covered
|
note: `Option<Option<Option<usize>>>` defined here
--> $SRC_DIR/core/src/option.rs:LL:COL
@@ -97,19 +97,19 @@ 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 a wildcard `_` is necessary to match exhaustively
+ = 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 => (),
-LL ~ Some(Some(Some(_))) => todo!(),
+LL ~ Some(Some(Some(usize::MAX..))) => todo!(),
|
-error[E0004]: non-exhaustive patterns: `A { .. }` not covered
+error[E0004]: non-exhaustive patterns: `A { a: usize::MAX.. }` not covered
--> $DIR/issue-85222-types-containing-non-exhaustive-types.rs:48:11
|
LL | match (A { a: 0usize }) {
- | ^^^^^^^^^^^^^^^^^ pattern `A { .. }` not covered
+ | ^^^^^^^^^^^^^^^^^ pattern `A { a: usize::MAX.. }` not covered
|
note: `A<usize>` defined here
--> $DIR/issue-85222-types-containing-non-exhaustive-types.rs:1:8
@@ -117,19 +117,19 @@ note: `A<usize>` defined here
LL | struct A<T> {
| ^
= note: the matched value is of type `A<usize>`
- = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively
+ = 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 } => (),
-LL ~ A { .. } => todo!(),
+LL ~ A { a: usize::MAX.. } => todo!(),
|
-error[E0004]: non-exhaustive patterns: `B(_, _)` not covered
+error[E0004]: non-exhaustive patterns: `B(..isize::MIN, _)` and `B(isize::MAX.., _)` not covered
--> $DIR/issue-85222-types-containing-non-exhaustive-types.rs:54:11
|
LL | match B(0isize, 0usize) {
- | ^^^^^^^^^^^^^^^^^ pattern `B(_, _)` not covered
+ | ^^^^^^^^^^^^^^^^^ patterns `B(..isize::MIN, _)` and `B(isize::MAX.., _)` not covered
|
note: `B<isize, usize>` defined here
--> $DIR/issue-85222-types-containing-non-exhaustive-types.rs:5:8
@@ -137,19 +137,19 @@ note: `B<isize, usize>` defined here
LL | struct B<T, U>(T, U);
| ^
= note: the matched value is of type `B<isize, usize>`
- = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively
+ = 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 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 ~ B(isize::MIN..=isize::MAX, 1..=usize::MAX) => (),
-LL ~ B(_, _) => todo!(),
+LL ~ B(..isize::MIN, _) | B(isize::MAX.., _) => todo!(),
|
-error[E0004]: non-exhaustive patterns: `B(_, _)` not covered
+error[E0004]: non-exhaustive patterns: `B(_, usize::MAX..)` not covered
--> $DIR/issue-85222-types-containing-non-exhaustive-types.rs:62:11
|
LL | match B(0isize, 0usize) {
- | ^^^^^^^^^^^^^^^^^ pattern `B(_, _)` not covered
+ | ^^^^^^^^^^^^^^^^^ pattern `B(_, usize::MAX..)` not covered
|
note: `B<isize, usize>` defined here
--> $DIR/issue-85222-types-containing-non-exhaustive-types.rs:5:8
@@ -157,12 +157,12 @@ note: `B<isize, usize>` defined here
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 a wildcard `_` is necessary to match exhaustively
+ = 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) => (),
-LL ~ B(_, _) => todo!(),
+LL ~ B(_, usize::MAX..) => todo!(),
|
error: aborting due to 9 previous errors
diff --git a/tests/ui/pattern/usefulness/non-exhaustive-defined-here.rs b/tests/ui/pattern/usefulness/non-exhaustive-defined-here.rs
index 5145f7690..1d1ea8e49 100644
--- a/tests/ui/pattern/usefulness/non-exhaustive-defined-here.rs
+++ b/tests/ui/pattern/usefulness/non-exhaustive-defined-here.rs
@@ -1,10 +1,15 @@
+#![feature(custom_inner_attributes)]
+#![rustfmt::skip]
// Test the "defined here" and "not covered" diagnostic hints.
// We also make sure that references are peeled off from the scrutinee type
// so that the diagnostics work better with default binding modes.
#[derive(Clone)]
enum E {
- //~^ NOTE
+ //~^ NOTE `E` defined here
+ //~| NOTE `E` defined here
+ //~| NOTE `E` defined here
+ //~| NOTE
//~| NOTE
//~| NOTE
//~| NOTE
@@ -12,10 +17,7 @@ enum E {
//~| NOTE
A,
B,
- //~^ NOTE `E` defined here
- //~| NOTE `E` defined here
- //~| NOTE `E` defined here
- //~| NOTE not covered
+ //~^ NOTE not covered
//~| NOTE not covered
//~| NOTE not covered
//~| NOTE not covered
@@ -79,12 +81,12 @@ fn by_ref_thrice(e: & &mut &E) {
}
enum Opt {
- //~^ NOTE
+ //~^ NOTE `Opt` defined here
+ //~| NOTE
//~| NOTE
Some(u8),
None,
- //~^ NOTE `Opt` defined here
- //~| NOTE not covered
+ //~^ NOTE not covered
//~| NOTE not covered
}
diff --git a/tests/ui/pattern/usefulness/non-exhaustive-defined-here.stderr b/tests/ui/pattern/usefulness/non-exhaustive-defined-here.stderr
index 8489e2f14..a9e55fa53 100644
--- a/tests/ui/pattern/usefulness/non-exhaustive-defined-here.stderr
+++ b/tests/ui/pattern/usefulness/non-exhaustive-defined-here.stderr
@@ -1,20 +1,20 @@
error[E0004]: non-exhaustive patterns: `E::B` and `E::C` not covered
- --> $DIR/non-exhaustive-defined-here.rs:35:11
+ --> $DIR/non-exhaustive-defined-here.rs:37:11
|
LL | match e1 {
| ^^ patterns `E::B` and `E::C` not covered
|
note: `E` defined here
- --> $DIR/non-exhaustive-defined-here.rs:14:5
+ --> $DIR/non-exhaustive-defined-here.rs:8:6
|
LL | enum E {
- | -
+ | ^
...
LL | B,
- | ^ not covered
+ | - not covered
...
LL | C
- | ^ not covered
+ | - not covered
= note: the matched value is of type `E`
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
|
@@ -23,7 +23,7 @@ LL + E::B | E::C => todo!()
|
error[E0005]: refutable pattern in local binding
- --> $DIR/non-exhaustive-defined-here.rs:41:9
+ --> $DIR/non-exhaustive-defined-here.rs:43:9
|
LL | let E::A = e;
| ^^^^ patterns `E::B` and `E::C` not covered
@@ -31,7 +31,7 @@ LL | let E::A = e;
= 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: `E` defined here
- --> $DIR/non-exhaustive-defined-here.rs:6:6
+ --> $DIR/non-exhaustive-defined-here.rs:8:6
|
LL | enum E {
| ^
@@ -48,22 +48,22 @@ LL | if let E::A = e { todo!() };
| ++ +++++++++++
error[E0004]: non-exhaustive patterns: `&E::B` and `&E::C` not covered
- --> $DIR/non-exhaustive-defined-here.rs:50:11
+ --> $DIR/non-exhaustive-defined-here.rs:52:11
|
LL | match e {
| ^ patterns `&E::B` and `&E::C` not covered
|
note: `E` defined here
- --> $DIR/non-exhaustive-defined-here.rs:14:5
+ --> $DIR/non-exhaustive-defined-here.rs:8:6
|
LL | enum E {
- | -
+ | ^
...
LL | B,
- | ^ not covered
+ | - not covered
...
LL | C
- | ^ not covered
+ | - not covered
= note: the matched value is of type `&E`
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
|
@@ -72,7 +72,7 @@ LL + &E::B | &E::C => todo!()
|
error[E0005]: refutable pattern in local binding
- --> $DIR/non-exhaustive-defined-here.rs:57:9
+ --> $DIR/non-exhaustive-defined-here.rs:59:9
|
LL | let E::A = e;
| ^^^^ patterns `&E::B` and `&E::C` not covered
@@ -80,7 +80,7 @@ LL | let E::A = e;
= 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: `E` defined here
- --> $DIR/non-exhaustive-defined-here.rs:6:6
+ --> $DIR/non-exhaustive-defined-here.rs:8:6
|
LL | enum E {
| ^
@@ -97,22 +97,22 @@ LL | if let E::A = e { todo!() };
| ++ +++++++++++
error[E0004]: non-exhaustive patterns: `&&mut &E::B` and `&&mut &E::C` not covered
- --> $DIR/non-exhaustive-defined-here.rs:66:11
+ --> $DIR/non-exhaustive-defined-here.rs:68:11
|
LL | match e {
| ^ patterns `&&mut &E::B` and `&&mut &E::C` not covered
|
note: `E` defined here
- --> $DIR/non-exhaustive-defined-here.rs:14:5
+ --> $DIR/non-exhaustive-defined-here.rs:8:6
|
LL | enum E {
- | -
+ | ^
...
LL | B,
- | ^ not covered
+ | - not covered
...
LL | C
- | ^ not covered
+ | - not covered
= note: the matched value is of type `&&mut &E`
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
|
@@ -121,7 +121,7 @@ LL + &&mut &E::B | &&mut &E::C => todo!()
|
error[E0005]: refutable pattern in local binding
- --> $DIR/non-exhaustive-defined-here.rs:73:9
+ --> $DIR/non-exhaustive-defined-here.rs:75:9
|
LL | let E::A = e;
| ^^^^ patterns `&&mut &E::B` and `&&mut &E::C` not covered
@@ -129,7 +129,7 @@ LL | let E::A = e;
= 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: `E` defined here
- --> $DIR/non-exhaustive-defined-here.rs:6:6
+ --> $DIR/non-exhaustive-defined-here.rs:8:6
|
LL | enum E {
| ^
@@ -146,19 +146,19 @@ LL | if let E::A = e { todo!() };
| ++ +++++++++++
error[E0004]: non-exhaustive patterns: `Opt::None` not covered
- --> $DIR/non-exhaustive-defined-here.rs:92:11
+ --> $DIR/non-exhaustive-defined-here.rs:94:11
|
LL | match e {
| ^ pattern `Opt::None` not covered
|
note: `Opt` defined here
- --> $DIR/non-exhaustive-defined-here.rs:85:5
+ --> $DIR/non-exhaustive-defined-here.rs:83:6
|
LL | enum Opt {
- | ---
+ | ^^^
...
LL | None,
- | ^^^^ not covered
+ | ---- not covered
= note: the matched value is of type `Opt`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
@@ -167,7 +167,7 @@ LL + Opt::None => todo!()
|
error[E0005]: refutable pattern in local binding
- --> $DIR/non-exhaustive-defined-here.rs:99:9
+ --> $DIR/non-exhaustive-defined-here.rs:101:9
|
LL | let Opt::Some(ref _x) = e;
| ^^^^^^^^^^^^^^^^^ pattern `Opt::None` not covered
@@ -175,7 +175,7 @@ LL | let Opt::Some(ref _x) = e;
= 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: `Opt` defined here
- --> $DIR/non-exhaustive-defined-here.rs:81:6
+ --> $DIR/non-exhaustive-defined-here.rs:83:6
|
LL | enum Opt {
| ^^^
diff --git a/tests/ui/pattern/usefulness/non-exhaustive-match-nested.stderr b/tests/ui/pattern/usefulness/non-exhaustive-match-nested.stderr
index 98e417a17..310049fe1 100644
--- a/tests/ui/pattern/usefulness/non-exhaustive-match-nested.stderr
+++ b/tests/ui/pattern/usefulness/non-exhaustive-match-nested.stderr
@@ -18,10 +18,10 @@ LL | match x {
| ^ pattern `T::A(U::C)` not covered
|
note: `T` defined here
- --> $DIR/non-exhaustive-match-nested.rs:1:10
+ --> $DIR/non-exhaustive-match-nested.rs:1:6
|
LL | enum T { A(U), B }
- | - ^ not covered
+ | ^ - not covered
= note: the matched value is of type `T`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
diff --git a/tests/ui/pattern/usefulness/non-exhaustive-match.stderr b/tests/ui/pattern/usefulness/non-exhaustive-match.stderr
index e59e8885e..4bebd3cbb 100644
--- a/tests/ui/pattern/usefulness/non-exhaustive-match.stderr
+++ b/tests/ui/pattern/usefulness/non-exhaustive-match.stderr
@@ -5,10 +5,10 @@ LL | match x { T::B => { } }
| ^ pattern `T::A` not covered
|
note: `T` defined here
- --> $DIR/non-exhaustive-match.rs:3:10
+ --> $DIR/non-exhaustive-match.rs:3:6
|
LL | enum T { A, B }
- | - ^ not covered
+ | ^ - not covered
= note: the matched value is of type `T`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
@@ -79,10 +79,10 @@ LL | match T::A {
| ^^^^ pattern `T::B` not covered
|
note: `T` defined here
- --> $DIR/non-exhaustive-match.rs:3:13
+ --> $DIR/non-exhaustive-match.rs:3:6
|
LL | enum T { A, B }
- | - ^ not covered
+ | ^ - not covered
= note: the matched value is of type `T`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
diff --git a/tests/ui/pattern/usefulness/non-exhaustive-pattern-witness.rs b/tests/ui/pattern/usefulness/non-exhaustive-pattern-witness.rs
index 4bd344219..9e60d4f41 100644
--- a/tests/ui/pattern/usefulness/non-exhaustive-pattern-witness.rs
+++ b/tests/ui/pattern/usefulness/non-exhaustive-pattern-witness.rs
@@ -1,88 +1,101 @@
struct Foo {
first: bool,
- second: Option<[usize; 4]>
+ second: Option<[usize; 4]>,
}
fn struct_with_a_nested_enum_and_vector() {
match (Foo { first: true, second: None }) {
-//~^ ERROR non-exhaustive patterns: `Foo { first: false, second: Some([_, _, _, _]) }` not covered
+ //~^ ERROR non-exhaustive patterns: `Foo { first: false, second: Some([0_usize, _, _, _]) }` and `Foo { first: false, second: Some([2_usize.., _, _, _]) }` not covered
Foo { first: true, second: None } => (),
Foo { first: true, second: Some(_) } => (),
Foo { first: false, second: None } => (),
- Foo { first: false, second: Some([1, 2, 3, 4]) } => ()
+ Foo { first: false, second: Some([1, 2, 3, 4]) } => (),
}
}
enum Color {
Red,
Green,
- CustomRGBA { a: bool, r: u8, g: u8, b: u8 }
+ CustomRGBA { a: bool, r: u8, g: u8, b: u8 },
}
fn enum_with_single_missing_variant() {
match Color::Red {
- //~^ ERROR non-exhaustive patterns: `Color::Red` not covered
+ //~^ ERROR non-exhaustive patterns: `Color::Red` not covered
Color::CustomRGBA { .. } => (),
- Color::Green => ()
+ Color::Green => (),
}
}
enum Direction {
- North, East, South, West
+ North,
+ East,
+ South,
+ West,
}
fn enum_with_multiple_missing_variants() {
match Direction::North {
- //~^ ERROR non-exhaustive patterns: `Direction::East`, `Direction::South` and `Direction::West` not covered
- Direction::North => ()
+ //~^ ERROR non-exhaustive patterns: `Direction::East`, `Direction::South` and `Direction::West` not covered
+ Direction::North => (),
}
}
enum ExcessiveEnum {
- First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth, Tenth, Eleventh, Twelfth
+ First,
+ Second,
+ Third,
+ Fourth,
+ Fifth,
+ Sixth,
+ Seventh,
+ Eighth,
+ Ninth,
+ Tenth,
+ Eleventh,
+ Twelfth,
}
fn enum_with_excessive_missing_variants() {
match ExcessiveEnum::First {
- //~^ ERROR `ExcessiveEnum::Second`, `ExcessiveEnum::Third`, `ExcessiveEnum::Fourth` and 8 more not covered
-
- ExcessiveEnum::First => ()
+ //~^ ERROR `ExcessiveEnum::Second`, `ExcessiveEnum::Third`, `ExcessiveEnum::Fourth` and 8 more not covered
+ ExcessiveEnum::First => (),
}
}
fn enum_struct_variant() {
match Color::Red {
- //~^ ERROR non-exhaustive patterns: `Color::CustomRGBA { a: true, .. }` not covered
+ //~^ ERROR non-exhaustive patterns: `Color::CustomRGBA { a: true, .. }` not covered
Color::Red => (),
Color::Green => (),
Color::CustomRGBA { a: false, r: _, g: _, b: 0 } => (),
- Color::CustomRGBA { a: false, r: _, g: _, b: _ } => ()
+ Color::CustomRGBA { a: false, r: _, g: _, b: _ } => (),
}
}
enum Enum {
First,
- Second(bool)
+ Second(bool),
}
fn vectors_with_nested_enums() {
let x: &'static [Enum] = &[Enum::First, Enum::Second(false)];
match *x {
- //~^ ERROR non-exhaustive patterns: `[Enum::Second(true), Enum::Second(false)]` not covered
+ //~^ ERROR non-exhaustive patterns: `[Enum::Second(true), Enum::Second(false)]` not covered
[] => (),
[_] => (),
[Enum::First, _] => (),
[Enum::Second(true), Enum::First] => (),
[Enum::Second(true), Enum::Second(true)] => (),
[Enum::Second(false), _] => (),
- [_, _, ref tail @ .., _] => ()
+ [_, _, ref tail @ .., _] => (),
}
}
fn missing_nil() {
match ((), false) {
- //~^ ERROR non-exhaustive patterns: `((), false)` not covered
- ((), true) => ()
+ //~^ ERROR non-exhaustive patterns: `((), false)` not covered
+ ((), true) => (),
}
}
diff --git a/tests/ui/pattern/usefulness/non-exhaustive-pattern-witness.stderr b/tests/ui/pattern/usefulness/non-exhaustive-pattern-witness.stderr
index d798ec722..cceb1d8f6 100644
--- a/tests/ui/pattern/usefulness/non-exhaustive-pattern-witness.stderr
+++ b/tests/ui/pattern/usefulness/non-exhaustive-pattern-witness.stderr
@@ -1,8 +1,8 @@
-error[E0004]: non-exhaustive patterns: `Foo { first: false, second: Some([_, _, _, _]) }` not covered
+error[E0004]: non-exhaustive patterns: `Foo { first: false, second: Some([0_usize, _, _, _]) }` and `Foo { first: false, second: Some([2_usize.., _, _, _]) }` not covered
--> $DIR/non-exhaustive-pattern-witness.rs:7:11
|
LL | match (Foo { first: true, second: None }) {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `Foo { first: false, second: Some([_, _, _, _]) }` not covered
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ patterns `Foo { first: false, second: Some([0_usize, _, _, _]) }` and `Foo { first: false, second: Some([2_usize.., _, _, _]) }` not covered
|
note: `Foo` defined here
--> $DIR/non-exhaustive-pattern-witness.rs:1:8
@@ -10,12 +10,10 @@ note: `Foo` defined here
LL | struct Foo {
| ^^^
= note: the matched value is of type `Foo`
- = note: `usize` does not have a fixed maximum value, so a wildcard `_` is 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
+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 ~ Foo { first: false, second: Some([1, 2, 3, 4]) } => (),
-LL + Foo { first: false, second: Some([_, _, _, _]) } => todo!()
+LL ~ Foo { first: false, second: Some([0_usize, _, _, _]) } | Foo { first: false, second: Some([2_usize.., _, _, _]) } => todo!(),
|
error[E0004]: non-exhaustive patterns: `Color::Red` not covered
@@ -25,83 +23,96 @@ LL | match Color::Red {
| ^^^^^^^^^^ pattern `Color::Red` not covered
|
note: `Color` defined here
- --> $DIR/non-exhaustive-pattern-witness.rs:17:5
+ --> $DIR/non-exhaustive-pattern-witness.rs:16:6
|
LL | enum Color {
- | -----
+ | ^^^^^
LL | Red,
- | ^^^ not covered
+ | --- not covered
= note: the matched value is of type `Color`
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 ~ Color::Green => (),
-LL + Color::Red => todo!()
+LL ~ Color::Red => todo!(),
|
error[E0004]: non-exhaustive patterns: `Direction::East`, `Direction::South` and `Direction::West` not covered
- --> $DIR/non-exhaustive-pattern-witness.rs:35:11
+ --> $DIR/non-exhaustive-pattern-witness.rs:38:11
|
LL | match Direction::North {
| ^^^^^^^^^^^^^^^^ patterns `Direction::East`, `Direction::South` and `Direction::West` not covered
|
note: `Direction` defined here
- --> $DIR/non-exhaustive-pattern-witness.rs:31:12
+ --> $DIR/non-exhaustive-pattern-witness.rs:30:6
|
LL | enum Direction {
- | ---------
-LL | North, East, South, West
- | ^^^^ ^^^^^ ^^^^ not covered
- | | |
- | | not covered
- | not covered
+ | ^^^^^^^^^
+LL | North,
+LL | East,
+ | ---- not covered
+LL | South,
+ | ----- not covered
+LL | West,
+ | ---- not covered
= note: the matched value is of type `Direction`
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 ~ Direction::North => (),
-LL + Direction::East | Direction::South | Direction::West => todo!()
+LL ~ Direction::East | Direction::South | Direction::West => todo!(),
|
error[E0004]: non-exhaustive patterns: `ExcessiveEnum::Second`, `ExcessiveEnum::Third`, `ExcessiveEnum::Fourth` and 8 more not covered
- --> $DIR/non-exhaustive-pattern-witness.rs:46:11
+ --> $DIR/non-exhaustive-pattern-witness.rs:60:11
|
LL | match ExcessiveEnum::First {
| ^^^^^^^^^^^^^^^^^^^^ patterns `ExcessiveEnum::Second`, `ExcessiveEnum::Third`, `ExcessiveEnum::Fourth` and 8 more not covered
|
note: `ExcessiveEnum` defined here
- --> $DIR/non-exhaustive-pattern-witness.rs:41:6
+ --> $DIR/non-exhaustive-pattern-witness.rs:44:6
|
LL | enum ExcessiveEnum {
| ^^^^^^^^^^^^^
+LL | First,
+LL | Second,
+ | ------ not covered
+LL | Third,
+ | ----- not covered
+LL | Fourth,
+ | ------ not covered
+LL | Fifth,
+ | ----- not covered
+LL | Sixth,
+ | ----- not covered
= note: the matched value is of type `ExcessiveEnum`
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 ~ ExcessiveEnum::First => (),
-LL + _ => todo!()
+LL ~ _ => todo!(),
|
error[E0004]: non-exhaustive patterns: `Color::CustomRGBA { a: true, .. }` not covered
- --> $DIR/non-exhaustive-pattern-witness.rs:54:11
+ --> $DIR/non-exhaustive-pattern-witness.rs:67:11
|
LL | match Color::Red {
| ^^^^^^^^^^ pattern `Color::CustomRGBA { a: true, .. }` not covered
|
note: `Color` defined here
- --> $DIR/non-exhaustive-pattern-witness.rs:19:5
+ --> $DIR/non-exhaustive-pattern-witness.rs:16:6
|
LL | enum Color {
- | -----
+ | ^^^^^
...
-LL | CustomRGBA { a: bool, r: u8, g: u8, b: u8 }
- | ^^^^^^^^^^ not covered
+LL | CustomRGBA { a: bool, r: u8, g: u8, b: u8 },
+ | ---------- not covered
= note: the matched value is of type `Color`
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 ~ Color::CustomRGBA { a: false, r: _, g: _, b: _ } => (),
-LL + Color::CustomRGBA { a: true, .. } => todo!()
+LL ~ Color::CustomRGBA { a: true, .. } => todo!(),
|
error[E0004]: non-exhaustive patterns: `[Enum::Second(true), Enum::Second(false)]` not covered
- --> $DIR/non-exhaustive-pattern-witness.rs:70:11
+ --> $DIR/non-exhaustive-pattern-witness.rs:83:11
|
LL | match *x {
| ^^ pattern `[Enum::Second(true), Enum::Second(false)]` not covered
@@ -110,11 +121,11 @@ LL | match *x {
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 ~ [_, _, ref tail @ .., _] => (),
-LL + [Enum::Second(true), Enum::Second(false)] => todo!()
+LL ~ [Enum::Second(true), Enum::Second(false)] => todo!(),
|
error[E0004]: non-exhaustive patterns: `((), false)` not covered
- --> $DIR/non-exhaustive-pattern-witness.rs:83:11
+ --> $DIR/non-exhaustive-pattern-witness.rs:96:11
|
LL | match ((), false) {
| ^^^^^^^^^^^ pattern `((), false)` not covered
@@ -123,7 +134,7 @@ LL | match ((), false) {
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 ~ ((), true) => (),
-LL + ((), false) => todo!()
+LL ~ ((), false) => todo!(),
|
error: aborting due to 7 previous errors
diff --git a/tests/ui/pattern/usefulness/refutable-pattern-errors.rs b/tests/ui/pattern/usefulness/refutable-pattern-errors.rs
index 7a3e991d5..7603da1bb 100644
--- a/tests/ui/pattern/usefulness/refutable-pattern-errors.rs
+++ b/tests/ui/pattern/usefulness/refutable-pattern-errors.rs
@@ -1,6 +1,6 @@
-fn func((1, (Some(1), 2..=3)): (isize, (Option<isize>, isize))) { }
+fn func((1, (Some(1), 2..=3)): (isize, (Option<isize>, isize))) {}
//~^ ERROR refutable pattern in function argument
-//~| `(_, _)` not covered
+//~| `(..=0_isize, _)` and `(2_isize.., _)` not covered
fn main() {
let (1, (Some(1), 2..=3)) = (1, (None, 2));
diff --git a/tests/ui/pattern/usefulness/refutable-pattern-errors.stderr b/tests/ui/pattern/usefulness/refutable-pattern-errors.stderr
index beb51a4d4..e66cd1130 100644
--- a/tests/ui/pattern/usefulness/refutable-pattern-errors.stderr
+++ b/tests/ui/pattern/usefulness/refutable-pattern-errors.stderr
@@ -1,8 +1,8 @@
error[E0005]: refutable pattern in function argument
--> $DIR/refutable-pattern-errors.rs:1:9
|
-LL | fn func((1, (Some(1), 2..=3)): (isize, (Option<isize>, isize))) { }
- | ^^^^^^^^^^^^^^^^^^^^^ pattern `(_, _)` not covered
+LL | fn func((1, (Some(1), 2..=3)): (isize, (Option<isize>, isize))) {}
+ | ^^^^^^^^^^^^^^^^^^^^^ patterns `(..=0_isize, _)` and `(2_isize.., _)` not covered
|
= note: the matched value is of type `(isize, (Option<isize>, isize))`
diff --git a/tests/ui/pattern/usefulness/refutable-pattern-in-fn-arg.rs b/tests/ui/pattern/usefulness/refutable-pattern-in-fn-arg.rs
index 17dc38ab2..4203dd94d 100644
--- a/tests/ui/pattern/usefulness/refutable-pattern-in-fn-arg.rs
+++ b/tests/ui/pattern/usefulness/refutable-pattern-in-fn-arg.rs
@@ -1,6 +1,6 @@
fn main() {
let f = |3: isize| println!("hello");
//~^ ERROR refutable pattern in function argument
- //~| `_` not covered
+ //~| `..=2_isize` and `4_isize..` not covered
f(4);
}
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 ab3f6f69f..01f077909 100644
--- a/tests/ui/pattern/usefulness/refutable-pattern-in-fn-arg.stderr
+++ b/tests/ui/pattern/usefulness/refutable-pattern-in-fn-arg.stderr
@@ -2,7 +2,7 @@ error[E0005]: refutable pattern in function argument
--> $DIR/refutable-pattern-in-fn-arg.rs:2:14
|
LL | let f = |3: isize| println!("hello");
- | ^ pattern `_` not covered
+ | ^ patterns `..=2_isize` and `4_isize..` not covered
|
= note: the matched value is of type `isize`
help: alternatively, you could prepend the pattern with an underscore to define a new named variable; identifiers cannot begin with digits
diff --git a/tests/ui/pattern/usefulness/slice_of_empty.rs b/tests/ui/pattern/usefulness/slice_of_empty.rs
new file mode 100644
index 000000000..fe0688711
--- /dev/null
+++ b/tests/ui/pattern/usefulness/slice_of_empty.rs
@@ -0,0 +1,22 @@
+#![feature(never_type)]
+#![feature(exhaustive_patterns)]
+#![deny(unreachable_patterns)]
+
+fn main() {}
+
+fn foo(nevers: &[!]) {
+ match 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
new file mode 100644
index 000000000..07bb6b3a6
--- /dev/null
+++ b/tests/ui/pattern/usefulness/slice_of_empty.stderr
@@ -0,0 +1,39 @@
+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
+ |
+LL | match nevers {
+ | ^^^^^^ 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 | &[_] => (), &[] => todo!(),
+ | ++++++++++++++++
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0004`.
diff --git a/tests/ui/pattern/usefulness/stable-gated-patterns.stderr b/tests/ui/pattern/usefulness/stable-gated-patterns.stderr
index f944c25a9..f75517fb7 100644
--- a/tests/ui/pattern/usefulness/stable-gated-patterns.stderr
+++ b/tests/ui/pattern/usefulness/stable-gated-patterns.stderr
@@ -5,13 +5,13 @@ LL | match UnstableEnum::Stable {
| ^^^^^^^^^^^^^^^^^^^^ patterns `UnstableEnum::Stable2` and `_` not covered
|
note: `UnstableEnum` defined here
- --> $DIR/auxiliary/unstable.rs:9:5
+ --> $DIR/auxiliary/unstable.rs:5:1
|
LL | pub enum UnstableEnum {
- | ---------------------
+ | ^^^^^^^^^^^^^^^^^^^^^
...
LL | Stable2,
- | ^^^^^^^ not covered
+ | ------- not covered
= note: the matched value is of type `UnstableEnum`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
|
diff --git a/tests/ui/pattern/usefulness/struct-like-enum-nonexhaustive.stderr b/tests/ui/pattern/usefulness/struct-like-enum-nonexhaustive.stderr
index 22425aa0d..3d2b540a9 100644
--- a/tests/ui/pattern/usefulness/struct-like-enum-nonexhaustive.stderr
+++ b/tests/ui/pattern/usefulness/struct-like-enum-nonexhaustive.stderr
@@ -5,12 +5,12 @@ LL | match x {
| ^ pattern `A::B { x: Some(_) }` not covered
|
note: `A` defined here
- --> $DIR/struct-like-enum-nonexhaustive.rs:2:5
+ --> $DIR/struct-like-enum-nonexhaustive.rs:1:6
|
LL | enum A {
- | -
+ | ^
LL | B { x: Option<isize> },
- | ^ not covered
+ | - not covered
= note: the matched value is of type `A`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
diff --git a/tests/ui/pattern/usefulness/tuple-struct-nonexhaustive.stderr b/tests/ui/pattern/usefulness/tuple-struct-nonexhaustive.stderr
index 50c7fc889..ef707ed4a 100644
--- a/tests/ui/pattern/usefulness/tuple-struct-nonexhaustive.stderr
+++ b/tests/ui/pattern/usefulness/tuple-struct-nonexhaustive.stderr
@@ -1,8 +1,8 @@
-error[E0004]: non-exhaustive patterns: `Foo(_, _)` not covered
+error[E0004]: non-exhaustive patterns: `Foo(..=0_isize, _)` and `Foo(3_isize.., _)` not covered
--> $DIR/tuple-struct-nonexhaustive.rs:5:11
|
LL | match x {
- | ^ pattern `Foo(_, _)` not covered
+ | ^ patterns `Foo(..=0_isize, _)` and `Foo(3_isize.., _)` not covered
|
note: `Foo` defined here
--> $DIR/tuple-struct-nonexhaustive.rs:1:8
@@ -10,12 +10,10 @@ note: `Foo` defined here
LL | struct Foo(isize, isize);
| ^^^
= note: the matched value is of type `Foo`
- = note: `isize` does not have a fixed maximum value, so a wildcard `_` is 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 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 ~ Foo(2, b) => println!("{}", b),
-LL + Foo(_, _) => todo!()
+LL + Foo(..=0_isize, _) | Foo(3_isize.., _) => todo!()
|
error: aborting due to previous error
diff --git a/tests/ui/pattern/usefulness/unstable-gated-patterns.stderr b/tests/ui/pattern/usefulness/unstable-gated-patterns.stderr
index d776249b2..4a4945156 100644
--- a/tests/ui/pattern/usefulness/unstable-gated-patterns.stderr
+++ b/tests/ui/pattern/usefulness/unstable-gated-patterns.stderr
@@ -5,13 +5,13 @@ LL | match UnstableEnum::Stable {
| ^^^^^^^^^^^^^^^^^^^^ pattern `UnstableEnum::Unstable` not covered
|
note: `UnstableEnum` defined here
- --> $DIR/auxiliary/unstable.rs:11:5
+ --> $DIR/auxiliary/unstable.rs:5:1
|
LL | pub enum UnstableEnum {
- | ---------------------
+ | ^^^^^^^^^^^^^^^^^^^^^
...
LL | Unstable,
- | ^^^^^^^^ not covered
+ | -------- not covered
= note: the matched value is of type `UnstableEnum`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|