Skip to content

Commit 7a46a4f

Browse files
committed
Remove unnecessary allocation.
1 parent 15c64a1 commit 7a46a4f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

compiler/rustc_lint/src/builtin.rs

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

0 commit comments

Comments
 (0)