Skip to content

Commit 28edd7a

Browse files
committed
Use Symbol for dup check in #[rustc_must_implement_one_of]
1 parent f9174e1 commit 28edd7a

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

compiler/rustc_typeck/src/collect.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -1306,18 +1306,13 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: DefId) -> ty::TraitDef {
13061306
})
13071307
// Check for duplicates
13081308
.and_then(|list| {
1309-
let mut set: FxHashSet<&Ident> = FxHashSet::default();
1309+
let mut set: FxHashMap<Symbol, Span> = FxHashMap::default();
13101310
let mut no_dups = true;
13111311

13121312
for ident in &*list {
1313-
if let Some(dup) = set.replace(ident) {
1314-
let dup2 = set.get(&dup).copied().unwrap(); // We've just inserted it
1315-
1313+
if let Some(dup) = set.insert(ident.name, ident.span) {
13161314
tcx.sess
1317-
.struct_span_err(
1318-
vec![dup.span, dup2.span],
1319-
"Functions names are duplicated",
1320-
)
1315+
.struct_span_err(vec![dup, ident.span], "Functions names are duplicated")
13211316
.note(
13221317
"All `#[rustc_must_implement_one_of]` arguments \
13231318
must be unique",

0 commit comments

Comments
 (0)