@@ -43,6 +43,7 @@ use rustc_index::vec::Idx;
43
43
use rustc_middle:: lint:: LintDiagnosticBuilder ;
44
44
use rustc_middle:: ty:: print:: with_no_trimmed_paths;
45
45
use rustc_middle:: ty:: subst:: { GenericArgKind , Subst } ;
46
+ use rustc_middle:: ty:: Instance ;
46
47
use rustc_middle:: ty:: { self , layout:: LayoutError , Ty , TyCtxt } ;
47
48
use rustc_session:: Session ;
48
49
use rustc_span:: edition:: Edition ;
@@ -2595,7 +2596,7 @@ declare_lint! {
2595
2596
}
2596
2597
2597
2598
pub struct ClashingExternDeclarations {
2598
- seen_decls : FxHashMap < Symbol , HirId > ,
2599
+ seen_decls : FxHashMap < String , HirId > ,
2599
2600
}
2600
2601
2601
2602
/// Differentiate between whether the name for an extern decl came from the link_name attribute or
@@ -2626,16 +2627,17 @@ impl ClashingExternDeclarations {
2626
2627
fn insert ( & mut self , tcx : TyCtxt < ' _ > , fi : & hir:: ForeignItem < ' _ > ) -> Option < HirId > {
2627
2628
let hid = fi. hir_id ;
2628
2629
2629
- let name =
2630
- & tcx. codegen_fn_attrs ( tcx. hir ( ) . local_def_id ( hid) ) . link_name . unwrap_or ( fi. ident . name ) ;
2631
-
2632
- if self . seen_decls . contains_key ( name) {
2630
+ let local_did = tcx. hir ( ) . local_def_id ( fi. hir_id ) ;
2631
+ let did = local_did. to_def_id ( ) ;
2632
+ 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
2635
// Avoid updating the map with the new entry when we do find a collision. We want to
2634
2636
// make sure we're always pointing to the first definition as the previous declaration.
2635
2637
// This lets us avoid emitting "knock-on" diagnostics.
2636
- Some ( * self . seen_decls . get ( name) . unwrap ( ) )
2638
+ Some ( * self . seen_decls . get ( & name) . unwrap ( ) )
2637
2639
} else {
2638
- self . seen_decls . insert ( * name, hid)
2640
+ self . seen_decls . insert ( name, hid)
2639
2641
}
2640
2642
}
2641
2643
0 commit comments