about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_mir_build/messages.ftl6
-rw-r--r--compiler/rustc_mir_build/src/errors.rs6
-rw-r--r--compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs5
-rw-r--r--tests/ui/consts/const_in_pattern/issue-65466.stderr3
-rw-r--r--tests/ui/consts/const_in_pattern/reject_non_partial_eq.stderr3
-rw-r--r--tests/ui/match/issue-72896-non-partial-eq-const.stderr3
-rw-r--r--tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.stderr3
7 files changed, 22 insertions, 7 deletions
diff --git a/compiler/rustc_mir_build/messages.ftl b/compiler/rustc_mir_build/messages.ftl
index 6122307e5bb..f35252dbcc5 100644
--- a/compiler/rustc_mir_build/messages.ftl
+++ b/compiler/rustc_mir_build/messages.ftl
@@ -273,7 +273,7 @@ mir_build_non_exhaustive_patterns_type_not_empty = non-exhaustive patterns: type
     .suggestion = ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
     .help = ensure that all possible cases are being handled by adding a match arm with a wildcard pattern
 
-mir_build_non_partial_eq_match = constant of non-structural type `{$non_peq_ty}` in a pattern
+mir_build_non_partial_eq_match = constant of non-structural type `{$ty}` in a pattern
     .label = constant of non-structural type
 
 mir_build_pattern_not_covered = refutable pattern in {$origin}
@@ -322,9 +322,9 @@ mir_build_trailing_irrefutable_let_patterns = trailing irrefutable {$count ->
         *[other] them
     } into the body
 
-mir_build_type_not_structural = constant of non-structural type `{$non_sm_ty}` in a pattern
+mir_build_type_not_structural = constant of non-structural type `{$ty}` in a pattern
     .label = constant of non-structural type
-mir_build_type_not_structural_def = `{$non_sm_ty}` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
+mir_build_type_not_structural_def = `{$ty}` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
 mir_build_type_not_structural_more_info = see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
 mir_build_type_not_structural_tip =
     the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
diff --git a/compiler/rustc_mir_build/src/errors.rs b/compiler/rustc_mir_build/src/errors.rs
index da4c78ddc4e..49e18891fca 100644
--- a/compiler/rustc_mir_build/src/errors.rs
+++ b/compiler/rustc_mir_build/src/errors.rs
@@ -888,7 +888,7 @@ pub(crate) struct TypeNotStructural<'tcx> {
     pub(crate) span: Span,
     #[label(mir_build_type_not_structural_def)]
     pub(crate) ty_def_span: Span,
-    pub(crate) non_sm_ty: Ty<'tcx>,
+    pub(crate) ty: Ty<'tcx>,
     #[note(mir_build_type_not_structural_tip)]
     pub(crate) manual_partialeq_impl_span: Option<Span>,
     #[note(mir_build_type_not_structural_more_info)]
@@ -897,11 +897,13 @@ pub(crate) struct TypeNotStructural<'tcx> {
 
 #[derive(Diagnostic)]
 #[diag(mir_build_non_partial_eq_match)]
+#[note(mir_build_type_not_structural_def)]
+#[note(mir_build_type_not_structural_more_info)]
 pub(crate) struct TypeNotPartialEq<'tcx> {
     #[primary_span]
     #[label]
     pub(crate) span: Span,
-    pub(crate) non_peq_ty: Ty<'tcx>,
+    pub(crate) ty: Ty<'tcx>,
 }
 
 #[derive(Diagnostic)]
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 36c84f68f73..123a439c645 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
@@ -190,7 +190,8 @@ impl<'tcx> ConstToPat<'tcx> {
         if !inlined_const_as_pat.references_error() {
             // Always check for `PartialEq` if we had no other errors yet.
             if !self.type_has_partial_eq_impl(ty) {
-                let err = TypeNotPartialEq { span: self.span, non_peq_ty: ty };
+                let err = TypeNotPartialEq { span: self.span, ty };
+                // FIXME: visit every type in `ty` and if it doesn't derive `PartialEq`, mention it.
                 return self.mk_err(self.tcx.dcx().create_err(err), ty);
             }
         }
@@ -265,7 +266,7 @@ impl<'tcx> ConstToPat<'tcx> {
                 });
                 let err = TypeNotStructural {
                     span,
-                    non_sm_ty: ty,
+                    ty,
                     ty_def_span,
                     manual_partialeq_impl_span,
                     manual_partialeq_impl_note: manual_partialeq_impl_span.is_none(),
diff --git a/tests/ui/consts/const_in_pattern/issue-65466.stderr b/tests/ui/consts/const_in_pattern/issue-65466.stderr
index c51d14d39f8..bd9748b5dda 100644
--- a/tests/ui/consts/const_in_pattern/issue-65466.stderr
+++ b/tests/ui/consts/const_in_pattern/issue-65466.stderr
@@ -6,6 +6,9 @@ LL | const C: &[O<B>] = &[O::None];
 ...
 LL |         C => (),
    |         ^ constant of non-structural type
+   |
+   = note: `&[O<B>]` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
+   = 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/consts/const_in_pattern/reject_non_partial_eq.stderr b/tests/ui/consts/const_in_pattern/reject_non_partial_eq.stderr
index 2c9cda7d185..0ef5286e689 100644
--- a/tests/ui/consts/const_in_pattern/reject_non_partial_eq.stderr
+++ b/tests/ui/consts/const_in_pattern/reject_non_partial_eq.stderr
@@ -6,6 +6,9 @@ LL | const NO_PARTIAL_EQ_NONE: Option<NoPartialEq> = None;
 ...
 LL |         NO_PARTIAL_EQ_NONE => println!("NO_PARTIAL_EQ_NONE"),
    |         ^^^^^^^^^^^^^^^^^^ constant of non-structural type
+   |
+   = note: `Option<NoPartialEq>` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
+   = 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/match/issue-72896-non-partial-eq-const.stderr b/tests/ui/match/issue-72896-non-partial-eq-const.stderr
index 47323b3cd22..4287fbc188d 100644
--- a/tests/ui/match/issue-72896-non-partial-eq-const.stderr
+++ b/tests/ui/match/issue-72896-non-partial-eq-const.stderr
@@ -6,6 +6,9 @@ LL | const CONST_SET: EnumSet<Enum8> = EnumSet { __enumset_underlying: 3 };
 ...
 LL |         CONST_SET => { /* ok */ }
    |         ^^^^^^^^^ constant of non-structural type
+   |
+   = note: `EnumSet<Enum8>` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
+   = 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/rfcs/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.stderr b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.stderr
index 33244b2841f..4f83ca02c28 100644
--- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.stderr
+++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.stderr
@@ -6,6 +6,9 @@ LL | const A: &[B] = &[];
 ...
 LL |         A => (),
    |         ^ constant of non-structural type
+   |
+   = note: `&[B]` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
+   = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
 
 error: aborting due to 1 previous error