Use Symbol for dup check in #[rustc_must_implement_one_of]

This commit is contained in:
Maybe Waffle 2022-01-15 02:04:58 +03:00
parent f9174e1d80
commit 28edd7ac09

View file

@ -1306,18 +1306,13 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: DefId) -> ty::TraitDef {
}) })
// Check for duplicates // Check for duplicates
.and_then(|list| { .and_then(|list| {
let mut set: FxHashSet<&Ident> = FxHashSet::default(); let mut set: FxHashMap<Symbol, Span> = FxHashMap::default();
let mut no_dups = true; let mut no_dups = true;
for ident in &*list { for ident in &*list {
if let Some(dup) = set.replace(ident) { if let Some(dup) = set.insert(ident.name, ident.span) {
let dup2 = set.get(&dup).copied().unwrap(); // We've just inserted it
tcx.sess tcx.sess
.struct_span_err( .struct_span_err(vec![dup, ident.span], "Functions names are duplicated")
vec![dup.span, dup2.span],
"Functions names are duplicated",
)
.note( .note(
"All `#[rustc_must_implement_one_of]` arguments \ "All `#[rustc_must_implement_one_of]` arguments \
must be unique", must be unique",