about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Scherer <github35764891676564198441@oli-obk.de>2020-09-23 17:03:31 +0200
committerOliver Scherer <github35764891676564198441@oli-obk.de>2020-09-23 17:03:31 +0200
commit177d0cef48879c7aea8d7dc5064407c454d36124 (patch)
tree2a83ee29556f6f9c1fabc5a3592a994929738caa
parentd486486afdb545e43a27326be07a92d5fc9ad387 (diff)
downloadrust-177d0cef48879c7aea8d7dc5064407c454d36124.tar.gz
rust-177d0cef48879c7aea8d7dc5064407c454d36124.zip
Deduplicate errors in const to pat conversion
-rw-r--r--compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs33
-rw-r--r--src/test/ui/consts/const_in_pattern/cross-crate-fail.rs2
-rw-r--r--src/test/ui/consts/const_in_pattern/cross-crate-fail.stderr16
-rw-r--r--src/test/ui/consts/const_in_pattern/no-eq-branch-fail.rs1
-rw-r--r--src/test/ui/consts/const_in_pattern/no-eq-branch-fail.stderr8
-rw-r--r--src/test/ui/consts/const_in_pattern/reject_non_partial_eq.rs1
-rw-r--r--src/test/ui/consts/const_in_pattern/reject_non_partial_eq.stderr8
-rw-r--r--src/test/ui/consts/const_in_pattern/reject_non_structural.rs10
-rw-r--r--src/test/ui/consts/const_in_pattern/reject_non_structural.stderr82
-rw-r--r--src/test/ui/match/issue-70972-dyn-trait.rs1
-rw-r--r--src/test/ui/match/issue-70972-dyn-trait.stderr8
-rw-r--r--src/test/ui/pattern/issue-71042-opaquely-typed-constant-used-in-pattern.rs1
-rw-r--r--src/test/ui/pattern/issue-71042-opaquely-typed-constant-used-in-pattern.stderr8
-rw-r--r--src/test/ui/rfc1445/cant-hide-behind-direct-struct-embedded.rs1
-rw-r--r--src/test/ui/rfc1445/cant-hide-behind-direct-struct-embedded.stderr8
-rw-r--r--src/test/ui/rfc1445/cant-hide-behind-direct-struct-param.rs1
-rw-r--r--src/test/ui/rfc1445/cant-hide-behind-direct-struct-param.stderr8
-rw-r--r--src/test/ui/rfc1445/match-forbidden-without-eq.rs1
-rw-r--r--src/test/ui/rfc1445/match-forbidden-without-eq.stderr12
-rw-r--r--src/test/ui/rfc1445/match-nonempty-array-forbidden-without-eq.rs1
-rw-r--r--src/test/ui/rfc1445/match-nonempty-array-forbidden-without-eq.stderr8
-rw-r--r--src/test/ui/rfc1445/match-requires-both-partialeq-and-eq.rs1
-rw-r--r--src/test/ui/rfc1445/match-requires-both-partialeq-and-eq.stderr8
-rw-r--r--src/test/ui/type-alias-impl-trait/structural-match-no-leak.rs1
-rw-r--r--src/test/ui/type-alias-impl-trait/structural-match-no-leak.stderr8
-rw-r--r--src/test/ui/type-alias-impl-trait/structural-match.rs1
-rw-r--r--src/test/ui/type-alias-impl-trait/structural-match.stderr8
-rw-r--r--src/test/ui/union/union-const-pat.rs1
-rw-r--r--src/test/ui/union/union-const-pat.stderr8
29 files changed, 55 insertions, 200 deletions
diff --git a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs
index 3c0dec64693..9af40acc6d6 100644
--- a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs
+++ b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs
@@ -252,7 +252,12 @@ impl<'a, 'tcx> ConstToPat<'a, 'tcx> {
             ty::Adt(adt_def, _) if adt_def.is_union() => {
                 // Matching on union fields is unsafe, we can't hide it in constants
                 self.saw_const_match_error.set(true);
-                tcx.sess.span_err(span, "cannot use unions in constant patterns");
+                let msg = "cannot use unions in constant patterns";
+                if self.include_lint_checks {
+                    tcx.sess.span_err(span, msg);
+                } else {
+                    tcx.sess.delay_span_bug(span, msg)
+                }
                 PatKind::Wild
             }
             ty::Adt(..)
@@ -267,7 +272,11 @@ impl<'a, 'tcx> ConstToPat<'a, 'tcx> {
                     cv.ty, cv.ty,
                 );
                 self.saw_const_match_error.set(true);
-                self.tcx().sess.span_err(self.span, &msg);
+                if self.include_lint_checks {
+                    tcx.sess.span_err(self.span, &msg);
+                } else {
+                    tcx.sess.delay_span_bug(self.span, &msg)
+                }
                 PatKind::Wild
             }
             // If the type is not structurally comparable, just emit the constant directly,
@@ -308,7 +317,11 @@ impl<'a, 'tcx> ConstToPat<'a, 'tcx> {
                     path, path,
                 );
                 self.saw_const_match_error.set(true);
-                tcx.sess.span_err(span, &msg);
+                if self.include_lint_checks {
+                    tcx.sess.span_err(span, &msg);
+                } else {
+                    tcx.sess.delay_span_bug(span, &msg)
+                }
                 PatKind::Wild
             }
             ty::Adt(adt_def, substs) if adt_def.is_enum() => {
@@ -340,7 +353,12 @@ impl<'a, 'tcx> ConstToPat<'a, 'tcx> {
                 // These are not allowed and will error elsewhere anyway.
                 ty::Dynamic(..) => {
                     self.saw_const_match_error.set(true);
-                    tcx.sess.span_err(span, &format!("`{}` cannot be used in patterns", cv.ty));
+                    let msg = format!("`{}` cannot be used in patterns", cv.ty);
+                    if self.include_lint_checks {
+                        tcx.sess.span_err(span, &msg);
+                    } else {
+                        tcx.sess.delay_span_bug(span, &msg)
+                    }
                     PatKind::Wild
                 }
                 // `&str` and `&[u8]` are represented as `ConstValue::Slice`, let's keep using this
@@ -427,7 +445,12 @@ impl<'a, 'tcx> ConstToPat<'a, 'tcx> {
             }
             _ => {
                 self.saw_const_match_error.set(true);
-                tcx.sess.span_err(span, &format!("`{}` cannot be used in patterns", cv.ty));
+                let msg = format!("`{}` cannot be used in patterns", cv.ty);
+                if self.include_lint_checks {
+                    tcx.sess.span_err(span, &msg);
+                } else {
+                    tcx.sess.delay_span_bug(span, &msg)
+                }
                 PatKind::Wild
             }
         };
diff --git a/src/test/ui/consts/const_in_pattern/cross-crate-fail.rs b/src/test/ui/consts/const_in_pattern/cross-crate-fail.rs
index 05c53e5edcc..ab297f54dff 100644
--- a/src/test/ui/consts/const_in_pattern/cross-crate-fail.rs
+++ b/src/test/ui/consts/const_in_pattern/cross-crate-fail.rs
@@ -12,7 +12,6 @@ fn main() {
     match None {
         consts::SOME => panic!(),
         //~^ must be annotated with `#[derive(PartialEq, Eq)]`
-        //~| must be annotated with `#[derive(PartialEq, Eq)]`
 
         _ => {}
     }
@@ -20,7 +19,6 @@ fn main() {
     match None {
         <Defaulted as consts::AssocConst>::SOME  => panic!(),
         //~^ must be annotated with `#[derive(PartialEq, Eq)]`
-        //~| must be annotated with `#[derive(PartialEq, Eq)]`
 
         _ => {}
     }
diff --git a/src/test/ui/consts/const_in_pattern/cross-crate-fail.stderr b/src/test/ui/consts/const_in_pattern/cross-crate-fail.stderr
index 95db19e342a..a8066a88c35 100644
--- a/src/test/ui/consts/const_in_pattern/cross-crate-fail.stderr
+++ b/src/test/ui/consts/const_in_pattern/cross-crate-fail.stderr
@@ -5,22 +5,10 @@ LL |         consts::SOME => panic!(),
    |         ^^^^^^^^^^^^
 
 error: to use a constant of type `CustomEq` in a pattern, `CustomEq` must be annotated with `#[derive(PartialEq, Eq)]`
-  --> $DIR/cross-crate-fail.rs:21:9
+  --> $DIR/cross-crate-fail.rs:20:9
    |
 LL |         <Defaulted as consts::AssocConst>::SOME  => panic!(),
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-error: to use a constant of type `CustomEq` in a pattern, `CustomEq` must be annotated with `#[derive(PartialEq, Eq)]`
-  --> $DIR/cross-crate-fail.rs:13:9
-   |
-LL |         consts::SOME => panic!(),
-   |         ^^^^^^^^^^^^
-
-error: to use a constant of type `CustomEq` in a pattern, `CustomEq` must be annotated with `#[derive(PartialEq, Eq)]`
-  --> $DIR/cross-crate-fail.rs:21:9
-   |
-LL |         <Defaulted as consts::AssocConst>::SOME  => panic!(),
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error: aborting due to 4 previous errors
+error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/consts/const_in_pattern/no-eq-branch-fail.rs b/src/test/ui/consts/const_in_pattern/no-eq-branch-fail.rs
index c7f02c615a0..fc80d51c72d 100644
--- a/src/test/ui/consts/const_in_pattern/no-eq-branch-fail.rs
+++ b/src/test/ui/consts/const_in_pattern/no-eq-branch-fail.rs
@@ -20,7 +20,6 @@ fn main() {
     match Foo::Qux(NoEq) {
         BAR_BAZ => panic!(),
         //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
-        //~| ERROR must be annotated with `#[derive(PartialEq, Eq)]`
         _ => {}
     }
 }
diff --git a/src/test/ui/consts/const_in_pattern/no-eq-branch-fail.stderr b/src/test/ui/consts/const_in_pattern/no-eq-branch-fail.stderr
index ee78c6f5c3e..e505dad69be 100644
--- a/src/test/ui/consts/const_in_pattern/no-eq-branch-fail.stderr
+++ b/src/test/ui/consts/const_in_pattern/no-eq-branch-fail.stderr
@@ -4,11 +4,5 @@ error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated wit
 LL |         BAR_BAZ => panic!(),
    |         ^^^^^^^
 
-error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq, Eq)]`
-  --> $DIR/no-eq-branch-fail.rs:21:9
-   |
-LL |         BAR_BAZ => panic!(),
-   |         ^^^^^^^
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error
 
diff --git a/src/test/ui/consts/const_in_pattern/reject_non_partial_eq.rs b/src/test/ui/consts/const_in_pattern/reject_non_partial_eq.rs
index b2b2daa830f..a8216901c02 100644
--- a/src/test/ui/consts/const_in_pattern/reject_non_partial_eq.rs
+++ b/src/test/ui/consts/const_in_pattern/reject_non_partial_eq.rs
@@ -27,7 +27,6 @@ fn main() {
     match None {
         NO_PARTIAL_EQ_NONE => println!("NO_PARTIAL_EQ_NONE"),
         //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
-        //~| ERROR must be annotated with `#[derive(PartialEq, Eq)]`
         _ => panic!("whoops"),
     }
 }
diff --git a/src/test/ui/consts/const_in_pattern/reject_non_partial_eq.stderr b/src/test/ui/consts/const_in_pattern/reject_non_partial_eq.stderr
index dc830d36003..8462c32ea80 100644
--- a/src/test/ui/consts/const_in_pattern/reject_non_partial_eq.stderr
+++ b/src/test/ui/consts/const_in_pattern/reject_non_partial_eq.stderr
@@ -4,11 +4,5 @@ error: to use a constant of type `Option<NoPartialEq>` in a pattern, `Option<NoP
 LL |         NO_PARTIAL_EQ_NONE => println!("NO_PARTIAL_EQ_NONE"),
    |         ^^^^^^^^^^^^^^^^^^
 
-error: to use a constant of type `Option<NoPartialEq>` in a pattern, `Option<NoPartialEq>` must be annotated with `#[derive(PartialEq, Eq)]`
-  --> $DIR/reject_non_partial_eq.rs:28:9
-   |
-LL |         NO_PARTIAL_EQ_NONE => println!("NO_PARTIAL_EQ_NONE"),
-   |         ^^^^^^^^^^^^^^^^^^
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error
 
diff --git a/src/test/ui/consts/const_in_pattern/reject_non_structural.rs b/src/test/ui/consts/const_in_pattern/reject_non_structural.rs
index bbeaeea1f87..7a8169bec45 100644
--- a/src/test/ui/consts/const_in_pattern/reject_non_structural.rs
+++ b/src/test/ui/consts/const_in_pattern/reject_non_structural.rs
@@ -39,51 +39,41 @@ fn main() {
     const ENUM: Derive<NoDerive> = Derive::Some(NoDerive);
     match Derive::Some(NoDerive) { ENUM => dbg!(ENUM), _ => panic!("whoops"), };
     //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
-    //~| ERROR must be annotated with `#[derive(PartialEq, Eq)]`
 
     const FIELD: OND = TrivialEq(Some(NoDerive)).0;
     match Some(NoDerive) { FIELD => dbg!(FIELD), _ => panic!("whoops"), };
     //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
-    //~| ERROR must be annotated with `#[derive(PartialEq, Eq)]`
 
     const NO_DERIVE_SOME: OND = Some(NoDerive);
     const INDIRECT: OND = NO_DERIVE_SOME;
     match Some(NoDerive) {INDIRECT => dbg!(INDIRECT), _ => panic!("whoops"), };
     //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
-    //~| ERROR must be annotated with `#[derive(PartialEq, Eq)]`
 
     const TUPLE: (OND, OND) = (None, Some(NoDerive));
     match (None, Some(NoDerive)) { TUPLE => dbg!(TUPLE), _ => panic!("whoops"), };
     //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
-    //~| ERROR must be annotated with `#[derive(PartialEq, Eq)]`
 
     const TYPE_ASCRIPTION: OND = Some(NoDerive): OND;
     match Some(NoDerive) { TYPE_ASCRIPTION => dbg!(TYPE_ASCRIPTION), _ => panic!("whoops"), };
     //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
-    //~| ERROR must be annotated with `#[derive(PartialEq, Eq)]`
 
     const ARRAY: [OND; 2] = [None, Some(NoDerive)];
     match [None, Some(NoDerive)] { ARRAY => dbg!(ARRAY), _ => panic!("whoops"), };
     //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
-    //~| ERROR must be annotated with `#[derive(PartialEq, Eq)]`
 
     const REPEAT: [OND; 2] = [Some(NoDerive); 2];
     match [Some(NoDerive); 2] { REPEAT => dbg!(REPEAT), _ => panic!("whoops"), };
     //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
     //~| ERROR must be annotated with `#[derive(PartialEq, Eq)]`
-    //~| ERROR must be annotated with `#[derive(PartialEq, Eq)]`
-    //~| ERROR must be annotated with `#[derive(PartialEq, Eq)]`
 
     trait Trait: Sized { const ASSOC: Option<Self>; }
     impl Trait for NoDerive { const ASSOC: Option<NoDerive> = Some(NoDerive); }
     match Some(NoDerive) { NoDerive::ASSOC => dbg!(NoDerive::ASSOC), _ => panic!("whoops"), };
     //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
-    //~| ERROR must be annotated with `#[derive(PartialEq, Eq)]`
 
     const BLOCK: OND = { NoDerive; Some(NoDerive) };
     match Some(NoDerive) { BLOCK => dbg!(BLOCK), _ => panic!("whoops"), };
     //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
-    //~| ERROR must be annotated with `#[derive(PartialEq, Eq)]`
 
     const ADDR_OF: &OND = &Some(NoDerive);
     match &Some(NoDerive) { ADDR_OF => dbg!(ADDR_OF), _ => panic!("whoops"), };
diff --git a/src/test/ui/consts/const_in_pattern/reject_non_structural.stderr b/src/test/ui/consts/const_in_pattern/reject_non_structural.stderr
index b1310cf101e..56405a55d69 100644
--- a/src/test/ui/consts/const_in_pattern/reject_non_structural.stderr
+++ b/src/test/ui/consts/const_in_pattern/reject_non_structural.stderr
@@ -5,61 +5,61 @@ LL |     match Derive::Some(NoDerive) { ENUM => dbg!(ENUM), _ => panic!("whoops"
    |                                    ^^^^
 
 error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
-  --> $DIR/reject_non_structural.rs:45:28
+  --> $DIR/reject_non_structural.rs:44:28
    |
 LL |     match Some(NoDerive) { FIELD => dbg!(FIELD), _ => panic!("whoops"), };
    |                            ^^^^^
 
 error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
-  --> $DIR/reject_non_structural.rs:51:27
+  --> $DIR/reject_non_structural.rs:49:27
    |
 LL |     match Some(NoDerive) {INDIRECT => dbg!(INDIRECT), _ => panic!("whoops"), };
    |                           ^^^^^^^^
 
 error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
-  --> $DIR/reject_non_structural.rs:56:36
+  --> $DIR/reject_non_structural.rs:53:36
    |
 LL |     match (None, Some(NoDerive)) { TUPLE => dbg!(TUPLE), _ => panic!("whoops"), };
    |                                    ^^^^^
 
 error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
-  --> $DIR/reject_non_structural.rs:61:28
+  --> $DIR/reject_non_structural.rs:57:28
    |
 LL |     match Some(NoDerive) { TYPE_ASCRIPTION => dbg!(TYPE_ASCRIPTION), _ => panic!("whoops"), };
    |                            ^^^^^^^^^^^^^^^
 
 error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
-  --> $DIR/reject_non_structural.rs:66:36
+  --> $DIR/reject_non_structural.rs:61:36
    |
 LL |     match [None, Some(NoDerive)] { ARRAY => dbg!(ARRAY), _ => panic!("whoops"), };
    |                                    ^^^^^
 
 error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
-  --> $DIR/reject_non_structural.rs:71:33
+  --> $DIR/reject_non_structural.rs:65:33
    |
 LL |     match [Some(NoDerive); 2] { REPEAT => dbg!(REPEAT), _ => panic!("whoops"), };
    |                                 ^^^^^^
 
 error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
-  --> $DIR/reject_non_structural.rs:71:33
+  --> $DIR/reject_non_structural.rs:65:33
    |
 LL |     match [Some(NoDerive); 2] { REPEAT => dbg!(REPEAT), _ => panic!("whoops"), };
    |                                 ^^^^^^
 
 error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
-  --> $DIR/reject_non_structural.rs:79:28
+  --> $DIR/reject_non_structural.rs:71:28
    |
 LL |     match Some(NoDerive) { NoDerive::ASSOC => dbg!(NoDerive::ASSOC), _ => panic!("whoops"), };
    |                            ^^^^^^^^^^^^^^^
 
 error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
-  --> $DIR/reject_non_structural.rs:84:28
+  --> $DIR/reject_non_structural.rs:75:28
    |
 LL |     match Some(NoDerive) { BLOCK => dbg!(BLOCK), _ => panic!("whoops"), };
    |                            ^^^^^
 
 warning: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
-  --> $DIR/reject_non_structural.rs:89:29
+  --> $DIR/reject_non_structural.rs:79:29
    |
 LL |     match &Some(NoDerive) { ADDR_OF => dbg!(ADDR_OF), _ => panic!("whoops"), };
    |                             ^^^^^^^
@@ -72,65 +72,5 @@ LL | #![warn(indirect_structural_match)]
    = 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>
 
-error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
-  --> $DIR/reject_non_structural.rs:40:36
-   |
-LL |     match Derive::Some(NoDerive) { ENUM => dbg!(ENUM), _ => panic!("whoops"), };
-   |                                    ^^^^
-
-error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
-  --> $DIR/reject_non_structural.rs:45:28
-   |
-LL |     match Some(NoDerive) { FIELD => dbg!(FIELD), _ => panic!("whoops"), };
-   |                            ^^^^^
-
-error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
-  --> $DIR/reject_non_structural.rs:51:27
-   |
-LL |     match Some(NoDerive) {INDIRECT => dbg!(INDIRECT), _ => panic!("whoops"), };
-   |                           ^^^^^^^^
-
-error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
-  --> $DIR/reject_non_structural.rs:56:36
-   |
-LL |     match (None, Some(NoDerive)) { TUPLE => dbg!(TUPLE), _ => panic!("whoops"), };
-   |                                    ^^^^^
-
-error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
-  --> $DIR/reject_non_structural.rs:61:28
-   |
-LL |     match Some(NoDerive) { TYPE_ASCRIPTION => dbg!(TYPE_ASCRIPTION), _ => panic!("whoops"), };
-   |                            ^^^^^^^^^^^^^^^
-
-error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
-  --> $DIR/reject_non_structural.rs:66:36
-   |
-LL |     match [None, Some(NoDerive)] { ARRAY => dbg!(ARRAY), _ => panic!("whoops"), };
-   |                                    ^^^^^
-
-error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
-  --> $DIR/reject_non_structural.rs:71:33
-   |
-LL |     match [Some(NoDerive); 2] { REPEAT => dbg!(REPEAT), _ => panic!("whoops"), };
-   |                                 ^^^^^^
-
-error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
-  --> $DIR/reject_non_structural.rs:71:33
-   |
-LL |     match [Some(NoDerive); 2] { REPEAT => dbg!(REPEAT), _ => panic!("whoops"), };
-   |                                 ^^^^^^
-
-error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
-  --> $DIR/reject_non_structural.rs:79:28
-   |
-LL |     match Some(NoDerive) { NoDerive::ASSOC => dbg!(NoDerive::ASSOC), _ => panic!("whoops"), };
-   |                            ^^^^^^^^^^^^^^^
-
-error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
-  --> $DIR/reject_non_structural.rs:84:28
-   |
-LL |     match Some(NoDerive) { BLOCK => dbg!(BLOCK), _ => panic!("whoops"), };
-   |                            ^^^^^
-
-error: aborting due to 20 previous errors; 1 warning emitted
+error: aborting due to 10 previous errors; 1 warning emitted
 
diff --git a/src/test/ui/match/issue-70972-dyn-trait.rs b/src/test/ui/match/issue-70972-dyn-trait.rs
index b69e2dab265..97d161c59ec 100644
--- a/src/test/ui/match/issue-70972-dyn-trait.rs
+++ b/src/test/ui/match/issue-70972-dyn-trait.rs
@@ -5,7 +5,6 @@ fn main() {
     match a {
         F => panic!(),
         //~^ ERROR `&dyn Send` cannot be used in patterns
-        //~| ERROR `&dyn Send` cannot be used in patterns
         _ => {}
     }
 }
diff --git a/src/test/ui/match/issue-70972-dyn-trait.stderr b/src/test/ui/match/issue-70972-dyn-trait.stderr
index 985799b3c83..7581070ebc1 100644
--- a/src/test/ui/match/issue-70972-dyn-trait.stderr
+++ b/src/test/ui/match/issue-70972-dyn-trait.stderr
@@ -4,11 +4,5 @@ error: `&dyn Send` cannot be used in patterns
 LL |         F => panic!(),
    |         ^
 
-error: `&dyn Send` cannot be used in patterns
-  --> $DIR/issue-70972-dyn-trait.rs:6:9
-   |
-LL |         F => panic!(),
-   |         ^
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error
 
diff --git a/src/test/ui/pattern/issue-71042-opaquely-typed-constant-used-in-pattern.rs b/src/test/ui/pattern/issue-71042-opaquely-typed-constant-used-in-pattern.rs
index 0c38b533a16..427f4cd8c78 100644
--- a/src/test/ui/pattern/issue-71042-opaquely-typed-constant-used-in-pattern.rs
+++ b/src/test/ui/pattern/issue-71042-opaquely-typed-constant-used-in-pattern.rs
@@ -5,7 +5,6 @@ fn main() {
     const C: impl Copy = 0;
     match C {
         C => {} //~ ERROR: `impl Copy` cannot be used in patterns
-        //~^ ERROR: `impl Copy` cannot be used in patterns
         _ => {}
     }
 }
diff --git a/src/test/ui/pattern/issue-71042-opaquely-typed-constant-used-in-pattern.stderr b/src/test/ui/pattern/issue-71042-opaquely-typed-constant-used-in-pattern.stderr
index ad6cc0aa3e3..c22e6eb9443 100644
--- a/src/test/ui/pattern/issue-71042-opaquely-typed-constant-used-in-pattern.stderr
+++ b/src/test/ui/pattern/issue-71042-opaquely-typed-constant-used-in-pattern.stderr
@@ -4,11 +4,5 @@ error: `impl Copy` cannot be used in patterns
 LL |         C => {}
    |         ^
 
-error: `impl Copy` cannot be used in patterns
-  --> $DIR/issue-71042-opaquely-typed-constant-used-in-pattern.rs:7:9
-   |
-LL |         C => {}
-   |         ^
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error
 
diff --git a/src/test/ui/rfc1445/cant-hide-behind-direct-struct-embedded.rs b/src/test/ui/rfc1445/cant-hide-behind-direct-struct-embedded.rs
index c663535e533..4a8a0949379 100644
--- a/src/test/ui/rfc1445/cant-hide-behind-direct-struct-embedded.rs
+++ b/src/test/ui/rfc1445/cant-hide-behind-direct-struct-embedded.rs
@@ -21,7 +21,6 @@ fn main() {
     match WRAP_DIRECT_INLINE {
         WRAP_DIRECT_INLINE => { panic!("WRAP_DIRECT_INLINE matched itself"); }
         //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
-        //~| ERROR must be annotated with `#[derive(PartialEq, Eq)]`
         _ => { println!("WRAP_DIRECT_INLINE did not match itself"); }
     }
 }
diff --git a/src/test/ui/rfc1445/cant-hide-behind-direct-struct-embedded.stderr b/src/test/ui/rfc1445/cant-hide-behind-direct-struct-embedded.stderr
index 9c7d1f3a18f..c73a6cf1326 100644
--- a/src/test/ui/rfc1445/cant-hide-behind-direct-struct-embedded.stderr
+++ b/src/test/ui/rfc1445/cant-hide-behind-direct-struct-embedded.stderr
@@ -4,11 +4,5 @@ error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be ann
 LL |         WRAP_DIRECT_INLINE => { panic!("WRAP_DIRECT_INLINE matched itself"); }
    |         ^^^^^^^^^^^^^^^^^^
 
-error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
-  --> $DIR/cant-hide-behind-direct-struct-embedded.rs:22:9
-   |
-LL |         WRAP_DIRECT_INLINE => { panic!("WRAP_DIRECT_INLINE matched itself"); }
-   |         ^^^^^^^^^^^^^^^^^^
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error
 
diff --git a/src/test/ui/rfc1445/cant-hide-behind-direct-struct-param.rs b/src/test/ui/rfc1445/cant-hide-behind-direct-struct-param.rs
index 872bf5a63ff..93022a23dbf 100644
--- a/src/test/ui/rfc1445/cant-hide-behind-direct-struct-param.rs
+++ b/src/test/ui/rfc1445/cant-hide-behind-direct-struct-param.rs
@@ -21,7 +21,6 @@ fn main() {
     match WRAP_DIRECT_PARAM {
         WRAP_DIRECT_PARAM => { panic!("WRAP_DIRECT_PARAM matched itself"); }
         //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
-        //~| ERROR must be annotated with `#[derive(PartialEq, Eq)]`
         _ => { println!("WRAP_DIRECT_PARAM did not match itself"); }
     }
 }
diff --git a/src/test/ui/rfc1445/cant-hide-behind-direct-struct-param.stderr b/src/test/ui/rfc1445/cant-hide-behind-direct-struct-param.stderr
index 6f49a8a0c9d..6fdf9db89b8 100644
--- a/src/test/ui/rfc1445/cant-hide-behind-direct-struct-param.stderr
+++ b/src/test/ui/rfc1445/cant-hide-behind-direct-struct-param.stderr
@@ -4,11 +4,5 @@ error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be ann
 LL |         WRAP_DIRECT_PARAM => { panic!("WRAP_DIRECT_PARAM matched itself"); }
    |         ^^^^^^^^^^^^^^^^^
 
-error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
-  --> $DIR/cant-hide-behind-direct-struct-param.rs:22:9
-   |
-LL |         WRAP_DIRECT_PARAM => { panic!("WRAP_DIRECT_PARAM matched itself"); }
-   |         ^^^^^^^^^^^^^^^^^
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error
 
diff --git a/src/test/ui/rfc1445/match-forbidden-without-eq.rs b/src/test/ui/rfc1445/match-forbidden-without-eq.rs
index 59141eac3e8..1cca2752061 100644
--- a/src/test/ui/rfc1445/match-forbidden-without-eq.rs
+++ b/src/test/ui/rfc1445/match-forbidden-without-eq.rs
@@ -12,7 +12,6 @@ fn main() {
     match y {
         FOO => { }
         //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
-        //~| ERROR must be annotated with `#[derive(PartialEq, Eq)]`
         _ => { }
     }
 
diff --git a/src/test/ui/rfc1445/match-forbidden-without-eq.stderr b/src/test/ui/rfc1445/match-forbidden-without-eq.stderr
index 1f26f0f11dc..02fa2398189 100644
--- a/src/test/ui/rfc1445/match-forbidden-without-eq.stderr
+++ b/src/test/ui/rfc1445/match-forbidden-without-eq.stderr
@@ -5,7 +5,7 @@ LL |         FOO => { }
    |         ^^^
 
 warning: floating-point types cannot be used in patterns
-  --> $DIR/match-forbidden-without-eq.rs:21:9
+  --> $DIR/match-forbidden-without-eq.rs:20:9
    |
 LL |         f32::INFINITY => { }
    |         ^^^^^^^^^^^^^
@@ -14,14 +14,8 @@ LL |         f32::INFINITY => { }
    = 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 #41620 <https://github.com/rust-lang/rust/issues/41620>
 
-error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq, Eq)]`
-  --> $DIR/match-forbidden-without-eq.rs:13:9
-   |
-LL |         FOO => { }
-   |         ^^^
-
 warning: floating-point types cannot be used in patterns
-  --> $DIR/match-forbidden-without-eq.rs:21:9
+  --> $DIR/match-forbidden-without-eq.rs:20:9
    |
 LL |         f32::INFINITY => { }
    |         ^^^^^^^^^^^^^
@@ -29,5 +23,5 @@ LL |         f32::INFINITY => { }
    = 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 #41620 <https://github.com/rust-lang/rust/issues/41620>
 
-error: aborting due to 2 previous errors; 2 warnings emitted
+error: aborting due to previous error; 2 warnings emitted
 
diff --git a/src/test/ui/rfc1445/match-nonempty-array-forbidden-without-eq.rs b/src/test/ui/rfc1445/match-nonempty-array-forbidden-without-eq.rs
index 4112e8f4517..151a475c919 100644
--- a/src/test/ui/rfc1445/match-nonempty-array-forbidden-without-eq.rs
+++ b/src/test/ui/rfc1445/match-nonempty-array-forbidden-without-eq.rs
@@ -15,6 +15,5 @@ fn main() {
     match [B(1)] {
         FOO => { }
         //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
-        //~| ERROR must be annotated with `#[derive(PartialEq, Eq)]`
     }
 }
diff --git a/src/test/ui/rfc1445/match-nonempty-array-forbidden-without-eq.stderr b/src/test/ui/rfc1445/match-nonempty-array-forbidden-without-eq.stderr
index 7e354bf9ade..371f8a0aa1d 100644
--- a/src/test/ui/rfc1445/match-nonempty-array-forbidden-without-eq.stderr
+++ b/src/test/ui/rfc1445/match-nonempty-array-forbidden-without-eq.stderr
@@ -4,11 +4,5 @@ error: to use a constant of type `B` in a pattern, `B` must be annotated with `#
 LL |         FOO => { }
    |         ^^^
 
-error: to use a constant of type `B` in a pattern, `B` must be annotated with `#[derive(PartialEq, Eq)]`
-  --> $DIR/match-nonempty-array-forbidden-without-eq.rs:16:9
-   |
-LL |         FOO => { }
-   |         ^^^
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error
 
diff --git a/src/test/ui/rfc1445/match-requires-both-partialeq-and-eq.rs b/src/test/ui/rfc1445/match-requires-both-partialeq-and-eq.rs
index 9530a1ffec4..6b7d94603b5 100644
--- a/src/test/ui/rfc1445/match-requires-both-partialeq-and-eq.rs
+++ b/src/test/ui/rfc1445/match-requires-both-partialeq-and-eq.rs
@@ -16,7 +16,6 @@ fn main() {
     match y {
         FOO => { }
         //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
-        //~| ERROR must be annotated with `#[derive(PartialEq, Eq)]`
         _ => { }
     }
 }
diff --git a/src/test/ui/rfc1445/match-requires-both-partialeq-and-eq.stderr b/src/test/ui/rfc1445/match-requires-both-partialeq-and-eq.stderr
index 7ef082852ba..4157cf65283 100644
--- a/src/test/ui/rfc1445/match-requires-both-partialeq-and-eq.stderr
+++ b/src/test/ui/rfc1445/match-requires-both-partialeq-and-eq.stderr
@@ -4,11 +4,5 @@ error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated wit
 LL |         FOO => { }
    |         ^^^
 
-error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq, Eq)]`
-  --> $DIR/match-requires-both-partialeq-and-eq.rs:17:9
-   |
-LL |         FOO => { }
-   |         ^^^
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error
 
diff --git a/src/test/ui/type-alias-impl-trait/structural-match-no-leak.rs b/src/test/ui/type-alias-impl-trait/structural-match-no-leak.rs
index 54fc4956b9b..d50835608fa 100644
--- a/src/test/ui/type-alias-impl-trait/structural-match-no-leak.rs
+++ b/src/test/ui/type-alias-impl-trait/structural-match-no-leak.rs
@@ -13,7 +13,6 @@ fn leak_free_test() {
     match todo!() {
         LEAK_FREE => (),
         //~^ `impl Send` cannot be used in patterns
-        //~| `impl Send` cannot be used in patterns
         _ => (),
     }
 }
diff --git a/src/test/ui/type-alias-impl-trait/structural-match-no-leak.stderr b/src/test/ui/type-alias-impl-trait/structural-match-no-leak.stderr
index 90b44f6598d..889c4fd4b04 100644
--- a/src/test/ui/type-alias-impl-trait/structural-match-no-leak.stderr
+++ b/src/test/ui/type-alias-impl-trait/structural-match-no-leak.stderr
@@ -4,11 +4,5 @@ error: `impl Send` cannot be used in patterns
 LL |         LEAK_FREE => (),
    |         ^^^^^^^^^
 
-error: `impl Send` cannot be used in patterns
-  --> $DIR/structural-match-no-leak.rs:14:9
-   |
-LL |         LEAK_FREE => (),
-   |         ^^^^^^^^^
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error
 
diff --git a/src/test/ui/type-alias-impl-trait/structural-match.rs b/src/test/ui/type-alias-impl-trait/structural-match.rs
index 5fe5bb4bdea..a3ff4ad1d47 100644
--- a/src/test/ui/type-alias-impl-trait/structural-match.rs
+++ b/src/test/ui/type-alias-impl-trait/structural-match.rs
@@ -14,7 +14,6 @@ fn test() {
     match todo!() {
         VALUE => (),
         //~^ `impl Send` cannot be used in patterns
-        //~| `impl Send` cannot be used in patterns
         _ => (),
     }
 }
diff --git a/src/test/ui/type-alias-impl-trait/structural-match.stderr b/src/test/ui/type-alias-impl-trait/structural-match.stderr
index 7aca3ba8640..262fd072613 100644
--- a/src/test/ui/type-alias-impl-trait/structural-match.stderr
+++ b/src/test/ui/type-alias-impl-trait/structural-match.stderr
@@ -4,11 +4,5 @@ error: `impl Send` cannot be used in patterns
 LL |         VALUE => (),
    |         ^^^^^
 
-error: `impl Send` cannot be used in patterns
-  --> $DIR/structural-match.rs:15:9
-   |
-LL |         VALUE => (),
-   |         ^^^^^
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error
 
diff --git a/src/test/ui/union/union-const-pat.rs b/src/test/ui/union/union-const-pat.rs
index cb2248cc6d1..e7cb248a201 100644
--- a/src/test/ui/union/union-const-pat.rs
+++ b/src/test/ui/union/union-const-pat.rs
@@ -8,7 +8,6 @@ const C: U = U { a: 10 };
 fn main() {
     match C {
         C => {} //~ ERROR cannot use unions in constant patterns
-                //~| ERROR cannot use unions in constant patterns
         _ => {}
     }
 }
diff --git a/src/test/ui/union/union-const-pat.stderr b/src/test/ui/union/union-const-pat.stderr
index bec720401b9..dc87f4de521 100644
--- a/src/test/ui/union/union-const-pat.stderr
+++ b/src/test/ui/union/union-const-pat.stderr
@@ -4,11 +4,5 @@ error: cannot use unions in constant patterns
 LL |         C => {}
    |         ^
 
-error: cannot use unions in constant patterns
-  --> $DIR/union-const-pat.rs:10:9
-   |
-LL |         C => {}
-   |         ^
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error