about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2024-12-26 01:35:43 +0000
committerEsteban Küber <esteban@kuber.com.ar>2025-01-11 01:10:29 +0000
commit91425d0ef8bfdfb7f11b7528d026d1a245743c79 (patch)
tree3b54b27cc43815e38207eec89622c4635c66b1c5
parent05c39438e295389e30a580a5376bbed83b1ddfa1 (diff)
downloadrust-91425d0ef8bfdfb7f11b7528d026d1a245743c79.tar.gz
rust-91425d0ef8bfdfb7f11b7528d026d1a245743c79.zip
Avoid duplicated note
-rw-r--r--compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs14
-rw-r--r--tests/ui/consts/const_in_pattern/non_structural_with_escaping_bounds.stderr1
2 files changed, 8 insertions, 7 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 a1d9b9024ab..814da66ff0a 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
@@ -381,10 +381,10 @@ fn extend_type_not_partial_eq<'tcx>(
         adts_without_partialeq: FxHashSet<Span>,
         /// The user has written `impl PartialEq for Ty` which means it's non-structual,
         /// but we don't have a span to point at, so we'll just add them as a `note`.
-        manual: Vec<Ty<'tcx>>,
+        manual: FxHashSet<Ty<'tcx>>,
         /// The type has no `PartialEq` implementation, neither manual or derived, but
         /// we don't have a span to point at, so we'll just add them as a `note`.
-        without: Vec<Ty<'tcx>>,
+        without: FxHashSet<Ty<'tcx>>,
     }
 
     impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for UsedParamsNeedInstantiationVisitor<'tcx> {
@@ -408,10 +408,10 @@ fn extend_type_not_partial_eq<'tcx>(
                         self.adts_without_partialeq.insert(ty_def_span);
                     }
                     (true, false, _, _) => {
-                        self.manual.push(ty);
+                        self.manual.insert(ty);
                     }
                     (false, _, _, _) => {
-                        self.without.push(ty);
+                        self.without.insert(ty);
                     }
                     _ => {}
                 };
@@ -424,8 +424,8 @@ fn extend_type_not_partial_eq<'tcx>(
         typing_env,
         adts_with_manual_partialeq: FxHashSet::default(),
         adts_without_partialeq: FxHashSet::default(),
-        manual: vec![],
-        without: vec![],
+        manual: FxHashSet::default(),
+        without: FxHashSet::default(),
     };
     v.visit_ty(ty);
     #[allow(rustc::potential_query_instability)] // Span labels will be sorted by the rendering
@@ -439,11 +439,13 @@ fn extend_type_not_partial_eq<'tcx>(
             "must be annotated with `#[derive(PartialEq)]` to be usable in patterns",
         );
     }
+    #[allow(rustc::potential_query_instability)] // Span labels will be sorted by the rendering
     for ty in v.manual {
         err.note(format!(
             "`{ty}` must be annotated with `#[derive(PartialEq)]` to be usable in patterns, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details"
         ));
     }
+    #[allow(rustc::potential_query_instability)] // Span labels will be sorted by the rendering
     for ty in v.without {
         err.note(format!(
             "`{ty}` must be annotated with `#[derive(PartialEq)]` to be usable in patterns"
diff --git a/tests/ui/consts/const_in_pattern/non_structural_with_escaping_bounds.stderr b/tests/ui/consts/const_in_pattern/non_structural_with_escaping_bounds.stderr
index 47378569084..5ec6ecc3070 100644
--- a/tests/ui/consts/const_in_pattern/non_structural_with_escaping_bounds.stderr
+++ b/tests/ui/consts/const_in_pattern/non_structural_with_escaping_bounds.stderr
@@ -9,7 +9,6 @@ LL |         C => (),
    |
    = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
    = note: `std::alloc::Global` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
-   = note: `std::alloc::Global` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
 
 error: aborting due to 1 previous error