Skip to content

Commit

Permalink
Use Symbol for dup check in #[rustc_must_implement_one_of]
Browse files Browse the repository at this point in the history
  • Loading branch information
WaffleLapkin committed Jan 14, 2022
1 parent f9174e1 commit 28edd7a
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions compiler/rustc_typeck/src/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1306,18 +1306,13 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: DefId) -> ty::TraitDef {
})
// Check for duplicates
.and_then(|list| {
let mut set: FxHashSet<&Ident> = FxHashSet::default();
let mut set: FxHashMap<Symbol, Span> = FxHashMap::default();
let mut no_dups = true;

for ident in &*list {
if let Some(dup) = set.replace(ident) {
let dup2 = set.get(&dup).copied().unwrap(); // We've just inserted it

if let Some(dup) = set.insert(ident.name, ident.span) {
tcx.sess
.struct_span_err(
vec![dup.span, dup2.span],
"Functions names are duplicated",
)
.struct_span_err(vec![dup, ident.span], "Functions names are duplicated")
.note(
"All `#[rustc_must_implement_one_of]` arguments \
must be unique",
Expand Down

0 comments on commit 28edd7a

Please sign in to comment.