about summary refs log tree commit diff
path: root/tests/ui/pattern/usefulness
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2023-09-26 09:39:41 +0200
committerRalf Jung <post@ralfj.de>2024-01-24 07:56:23 +0100
commit0df7810734d396d1a3082eee674d542c81c269d2 (patch)
tree645b4b7b3214be6a2cd6322f6357e3bf815a389b /tests/ui/pattern/usefulness
parenta58ec8ff03b3269b20104eb7eae407be48ab95a7 (diff)
remove StructuralEq trait
Diffstat (limited to 'tests/ui/pattern/usefulness')
-rw-r--r--tests/ui/pattern/usefulness/const-partial_eq-fallback-ice.rs2
-rw-r--r--tests/ui/pattern/usefulness/const-partial_eq-fallback-ice.stderr4
-rw-r--r--tests/ui/pattern/usefulness/consts-opaque.rs28
-rw-r--r--tests/ui/pattern/usefulness/consts-opaque.stderr190
4 files changed, 102 insertions, 122 deletions
diff --git a/tests/ui/pattern/usefulness/const-partial_eq-fallback-ice.rs b/tests/ui/pattern/usefulness/const-partial_eq-fallback-ice.rs
index 02599d7c05b..f34093ef149 100644
--- a/tests/ui/pattern/usefulness/const-partial_eq-fallback-ice.rs
+++ b/tests/ui/pattern/usefulness/const-partial_eq-fallback-ice.rs
@@ -12,7 +12,7 @@ const CONSTANT: &&MyType = &&MyType;
 
 fn main() {
     if let CONSTANT = &&MyType {
-        //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
+        //~^ ERROR must be annotated with `#[derive(PartialEq)]`
         println!("did match!");
     }
 }
diff --git a/tests/ui/pattern/usefulness/const-partial_eq-fallback-ice.stderr b/tests/ui/pattern/usefulness/const-partial_eq-fallback-ice.stderr
index 2352ecd0a47..0b4d9972758 100644
--- a/tests/ui/pattern/usefulness/const-partial_eq-fallback-ice.stderr
+++ b/tests/ui/pattern/usefulness/const-partial_eq-fallback-ice.stderr
@@ -1,11 +1,11 @@
-error: to use a constant of type `MyType` in a pattern, `MyType` must be annotated with `#[derive(PartialEq, Eq)]`
+error: to use a constant of type `MyType` in a pattern, `MyType` must be annotated with `#[derive(PartialEq)]`
   --> $DIR/const-partial_eq-fallback-ice.rs:14:12
    |
 LL |     if let CONSTANT = &&MyType {
    |            ^^^^^^^^
    |
    = note: the traits must be derived, manual `impl`s are not sufficient
-   = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
+   = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/pattern/usefulness/consts-opaque.rs b/tests/ui/pattern/usefulness/consts-opaque.rs
index 27e305a3972..3e461785182 100644
--- a/tests/ui/pattern/usefulness/consts-opaque.rs
+++ b/tests/ui/pattern/usefulness/consts-opaque.rs
@@ -29,65 +29,63 @@ const BAZ: Baz = Baz::Baz1;
 fn main() {
     match FOO {
         FOO => {}
-        //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
         _ => {}
     }
 
     match FOO_REF {
         FOO_REF => {}
-        //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
         Foo(_) => {}
     }
 
     // This used to cause an ICE (https://github.com/rust-lang/rust/issues/78071)
     match FOO_REF_REF {
         FOO_REF_REF => {}
-        //~^ WARNING must be annotated with `#[derive(PartialEq, Eq)]`
-        //~| WARNING this was previously accepted by the compiler but is being phased out
         Foo(_) => {}
     }
 
     match BAR {
         Bar => {}
         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 => {}
+        //~^ ERROR unreachable pattern
         _ => {}
+        //~^ ERROR unreachable pattern
     }
 
     match BAR {
         BAR => {}
-        //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
-        BAR => {}
-        //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
-        _ => {}
+        BAR => {} // should not be emitting unreachable warning
+        //~^ 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 => {}
+        Baz::Baz1 => {} // should not be emitting unreachable warning
+        //~^ ERROR unreachable pattern
         _ => {}
     }
 
     match BAZ {
         Baz::Baz1 => {}
         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
     }
 
     type Quux = fn(usize, usize) -> usize;
diff --git a/tests/ui/pattern/usefulness/consts-opaque.stderr b/tests/ui/pattern/usefulness/consts-opaque.stderr
index 09f72ba927e..0b1a2e2736e 100644
--- a/tests/ui/pattern/usefulness/consts-opaque.stderr
+++ b/tests/ui/pattern/usefulness/consts-opaque.stderr
@@ -1,98 +1,5 @@
-error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq, Eq)]`
-  --> $DIR/consts-opaque.rs:31:9
-   |
-LL |         FOO => {}
-   |         ^^^
-   |
-   = 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 `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq, Eq)]`
-  --> $DIR/consts-opaque.rs:37:9
-   |
-LL |         FOO_REF => {}
-   |         ^^^^^^^
-   |
-   = 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
-
-warning: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq, Eq)]`
-  --> $DIR/consts-opaque.rs:44:9
-   |
-LL |         FOO_REF_REF => {}
-   |         ^^^^^^^^^^^
-   |
-   = 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/62411>
-   = 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
-   = 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:52:9
-   |
-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:58:9
-   |
-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:65:9
-   |
-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:67:9
-   |
-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:73:9
-   |
-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: to use a constant of type `Baz` in a pattern, `Baz` must be annotated with `#[derive(PartialEq, Eq)]`
-  --> $DIR/consts-opaque.rs:81:9
-   |
-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: to use a constant of type `Baz` in a pattern, `Baz` must be annotated with `#[derive(PartialEq, Eq)]`
-  --> $DIR/consts-opaque.rs:87:9
-   |
-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
-
 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
+  --> $DIR/consts-opaque.rs:96:9
    |
 LL |         QUUX => {}
    |         ^^^^
@@ -102,7 +9,7 @@ LL |         QUUX => {}
    = note: `#[warn(pointer_structural_match)]` on by default
 
 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
+  --> $DIR/consts-opaque.rs:98:9
    |
 LL |         QUUX => {}
    |         ^^^^
@@ -111,7 +18,7 @@ LL |         QUUX => {}
    = note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/70861>
 
 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
+  --> $DIR/consts-opaque.rs:108:9
    |
 LL |         WRAPQUUX => {}
    |         ^^^^^^^^
@@ -120,7 +27,7 @@ LL |         WRAPQUUX => {}
    = note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/70861>
 
 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
+  --> $DIR/consts-opaque.rs:110:9
    |
 LL |         WRAPQUUX => {}
    |         ^^^^^^^^
@@ -129,7 +36,7 @@ LL |         WRAPQUUX => {}
    = note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/70861>
 
 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
+  --> $DIR/consts-opaque.rs:117:9
    |
 LL |         WRAPQUUX => {}
    |         ^^^^^^^^
@@ -138,7 +45,7 @@ LL |         WRAPQUUX => {}
    = note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/70861>
 
 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
+  --> $DIR/consts-opaque.rs:127:9
    |
 LL |         WRAPQUUX => {}
    |         ^^^^^^^^
@@ -147,7 +54,7 @@ LL |         WRAPQUUX => {}
    = note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/70861>
 
 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
+  --> $DIR/consts-opaque.rs:139:9
    |
 LL |         WHOKNOWSQUUX => {}
    |         ^^^^^^^^^^^^
@@ -156,7 +63,7 @@ LL |         WHOKNOWSQUUX => {}
    = note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/70861>
 
 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
+  --> $DIR/consts-opaque.rs:142:9
    |
 LL |         WHOKNOWSQUUX => {}
    |         ^^^^^^^^^^^^
@@ -164,14 +71,89 @@ 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:48:9
+   |
+LL |         Bar => {}
+   |         --- matches any value
+LL |         BAR => {}
+   |         ^^^ unreachable pattern
+   |
+note: the lint level is defined here
+  --> $DIR/consts-opaque.rs:6:9
+   |
+LL | #![deny(unreachable_patterns)]
+   |         ^^^^^^^^^^^^^^^^^^^^
+
+error: unreachable pattern
+  --> $DIR/consts-opaque.rs:50:9
+   |
+LL |         Bar => {}
+   |         --- matches any value
+...
+LL |         _ => {}
+   |         ^ unreachable pattern
+
+error: unreachable pattern
+  --> $DIR/consts-opaque.rs:56:9
+   |
+LL |         BAR => {}
+   |         --- matches any value
+LL |         Bar => {}
+   |         ^^^ unreachable pattern
+
+error: unreachable pattern
+  --> $DIR/consts-opaque.rs:58:9
+   |
+LL |         BAR => {}
+   |         --- matches any value
+...
+LL |         _ => {}
+   |         ^ unreachable pattern
+
+error: unreachable pattern
+  --> $DIR/consts-opaque.rs:64:9
+   |
+LL |         BAR => {}
+   |         --- matches any value
+LL |         BAR => {} // should not be emitting unreachable warning
+   |         ^^^ unreachable pattern
+
+error: unreachable pattern
+  --> $DIR/consts-opaque.rs:66:9
+   |
+LL |         BAR => {}
+   |         --- matches any value
+...
+LL |         _ => {} // should not be emitting unreachable warning
+   |         ^ unreachable pattern
+
+error: unreachable pattern
+  --> $DIR/consts-opaque.rs:72:9
+   |
+LL |         Baz::Baz1 => {} // should not be emitting unreachable warning
+   |         ^^^^^^^^^
+
+error: unreachable pattern
+  --> $DIR/consts-opaque.rs:79:9
+   |
+LL |         BAZ => {}
+   |         ^^^
+
+error: unreachable pattern
+  --> $DIR/consts-opaque.rs:87:9
+   |
+LL |         _ => {} // should not be emitting unreachable warning
+   |         ^
+
 error[E0004]: non-exhaustive patterns: `Wrap(_)` not covered
-  --> $DIR/consts-opaque.rs:127:11
+  --> $DIR/consts-opaque.rs:125:11
    |
 LL |     match WRAPQUUX {
    |           ^^^^^^^^ pattern `Wrap(_)` not covered
    |
 note: `Wrap<fn(usize, usize) -> usize>` defined here
-  --> $DIR/consts-opaque.rs:106:12
+  --> $DIR/consts-opaque.rs:104:12
    |
 LL |     struct Wrap<T>(T);
    |            ^^^^
@@ -181,6 +163,6 @@ help: ensure that all possible cases are being handled by adding a match arm wit
 LL |         WRAPQUUX => {}, Wrap(_) => todo!()
    |                       ++++++++++++++++++++
 
-error: aborting due to 10 previous errors; 9 warnings emitted
+error: aborting due to 10 previous errors; 8 warnings emitted
 
 For more information about this error, try `rustc --explain E0004`.