Remove unnecessary allocation.

This commit is contained in:
jumbatm 2020-12-23 00:26:04 +10:00
parent 15c64a181b
commit 7a46a4f219

View file

@ -2630,14 +2630,14 @@ impl ClashingExternDeclarations {
let local_did = tcx.hir().local_def_id(fi.hir_id); let local_did = tcx.hir().local_def_id(fi.hir_id);
let did = local_did.to_def_id(); let did = local_did.to_def_id();
let instance = Instance::new(did, ty::List::identity_for_item(tcx, did)); let instance = Instance::new(did, ty::List::identity_for_item(tcx, did));
let name = tcx.symbol_name(instance).name.to_string(); let name = tcx.symbol_name(instance).name;
if self.seen_decls.contains_key(&name) { if let Some(&hir_id) = self.seen_decls.get(name) {
// Avoid updating the map with the new entry when we do find a collision. We want to // Avoid updating the map with the new entry when we do find a collision. We want to
// make sure we're always pointing to the first definition as the previous declaration. // make sure we're always pointing to the first definition as the previous declaration.
// This lets us avoid emitting "knock-on" diagnostics. // This lets us avoid emitting "knock-on" diagnostics.
Some(*self.seen_decls.get(&name).unwrap()) Some(hir_id)
} else { } else {
self.seen_decls.insert(name, hid) self.seen_decls.insert(name.to_owned(), hid)
} }
} }