Skip to content

Commit 91425d0

Browse files
committed
Avoid duplicated note
1 parent 05c3943 commit 91425d0

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -381,10 +381,10 @@ fn extend_type_not_partial_eq<'tcx>(
381381
adts_without_partialeq: FxHashSet<Span>,
382382
/// The user has written `impl PartialEq for Ty` which means it's non-structual,
383383
/// but we don't have a span to point at, so we'll just add them as a `note`.
384-
manual: Vec<Ty<'tcx>>,
384+
manual: FxHashSet<Ty<'tcx>>,
385385
/// The type has no `PartialEq` implementation, neither manual or derived, but
386386
/// we don't have a span to point at, so we'll just add them as a `note`.
387-
without: Vec<Ty<'tcx>>,
387+
without: FxHashSet<Ty<'tcx>>,
388388
}
389389

390390
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for UsedParamsNeedInstantiationVisitor<'tcx> {
@@ -408,10 +408,10 @@ fn extend_type_not_partial_eq<'tcx>(
408408
self.adts_without_partialeq.insert(ty_def_span);
409409
}
410410
(true, false, _, _) => {
411-
self.manual.push(ty);
411+
self.manual.insert(ty);
412412
}
413413
(false, _, _, _) => {
414-
self.without.push(ty);
414+
self.without.insert(ty);
415415
}
416416
_ => {}
417417
};
@@ -424,8 +424,8 @@ fn extend_type_not_partial_eq<'tcx>(
424424
typing_env,
425425
adts_with_manual_partialeq: FxHashSet::default(),
426426
adts_without_partialeq: FxHashSet::default(),
427-
manual: vec![],
428-
without: vec![],
427+
manual: FxHashSet::default(),
428+
without: FxHashSet::default(),
429429
};
430430
v.visit_ty(ty);
431431
#[allow(rustc::potential_query_instability)] // Span labels will be sorted by the rendering
@@ -439,11 +439,13 @@ fn extend_type_not_partial_eq<'tcx>(
439439
"must be annotated with `#[derive(PartialEq)]` to be usable in patterns",
440440
);
441441
}
442+
#[allow(rustc::potential_query_instability)] // Span labels will be sorted by the rendering
442443
for ty in v.manual {
443444
err.note(format!(
444445
"`{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"
445446
));
446447
}
448+
#[allow(rustc::potential_query_instability)] // Span labels will be sorted by the rendering
447449
for ty in v.without {
448450
err.note(format!(
449451
"`{ty}` must be annotated with `#[derive(PartialEq)]` to be usable in patterns"

tests/ui/consts/const_in_pattern/non_structural_with_escaping_bounds.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ LL | C => (),
99
|
1010
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
1111
= note: `std::alloc::Global` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
12-
= note: `std::alloc::Global` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
1312

1413
error: aborting due to 1 previous error
1514

0 commit comments

Comments
 (0)