@@ -660,11 +660,10 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
660660 }
661661
662662 fn check_foreign_item ( & mut self , cx : & LateContext < ' _ > , foreign_item : & hir:: ForeignItem < ' _ > ) {
663- let def_id = cx. tcx . hir ( ) . local_def_id ( foreign_item. hir_id ) ;
664- let ( article, desc) = cx. tcx . article_and_description ( def_id. to_def_id ( ) ) ;
663+ let ( article, desc) = cx. tcx . article_and_description ( foreign_item. def_id . to_def_id ( ) ) ;
665664 self . check_missing_docs_attrs (
666665 cx,
667- Some ( foreign_item. hir_id ) ,
666+ Some ( foreign_item. hir_id ( ) ) ,
668667 & foreign_item. attrs ,
669668 foreign_item. span ,
670669 article,
@@ -1365,7 +1364,7 @@ impl<'tcx> LateLintPass<'tcx> for UnreachablePub {
13651364 self . perform_lint (
13661365 cx,
13671366 "item" ,
1368- foreign_item. hir_id ,
1367+ foreign_item. hir_id ( ) ,
13691368 & foreign_item. vis ,
13701369 foreign_item. span ,
13711370 true ,
@@ -2675,10 +2674,7 @@ impl ClashingExternDeclarations {
26752674 /// Insert a new foreign item into the seen set. If a symbol with the same name already exists
26762675 /// for the item, return its HirId without updating the set.
26772676 fn insert ( & mut self , tcx : TyCtxt < ' _ > , fi : & hir:: ForeignItem < ' _ > ) -> Option < HirId > {
2678- let hid = fi. hir_id ;
2679-
2680- let local_did = tcx. hir ( ) . local_def_id ( fi. hir_id ) ;
2681- let did = local_did. to_def_id ( ) ;
2677+ let did = fi. def_id . to_def_id ( ) ;
26822678 let instance = Instance :: new ( did, ty:: List :: identity_for_item ( tcx, did) ) ;
26832679 let name = Symbol :: intern ( tcx. symbol_name ( instance) . name ) ;
26842680 if let Some ( & hir_id) = self . seen_decls . get ( & name) {
@@ -2687,24 +2683,23 @@ impl ClashingExternDeclarations {
26872683 // This lets us avoid emitting "knock-on" diagnostics.
26882684 Some ( hir_id)
26892685 } else {
2690- self . seen_decls . insert ( name, hid )
2686+ self . seen_decls . insert ( name, fi . hir_id ( ) )
26912687 }
26922688 }
26932689
26942690 /// Get the name of the symbol that's linked against for a given extern declaration. That is,
26952691 /// the name specified in a #[link_name = ...] attribute if one was specified, else, just the
26962692 /// symbol's name.
26972693 fn name_of_extern_decl ( tcx : TyCtxt < ' _ > , fi : & hir:: ForeignItem < ' _ > ) -> SymbolName {
2698- let did = tcx. hir ( ) . local_def_id ( fi. hir_id ) ;
26992694 if let Some ( ( overridden_link_name, overridden_link_name_span) ) =
2700- tcx. codegen_fn_attrs ( did ) . link_name . map ( |overridden_link_name| {
2695+ tcx. codegen_fn_attrs ( fi . def_id ) . link_name . map ( |overridden_link_name| {
27012696 // FIXME: Instead of searching through the attributes again to get span
27022697 // information, we could have codegen_fn_attrs also give span information back for
27032698 // where the attribute was defined. However, until this is found to be a
27042699 // bottleneck, this does just fine.
27052700 (
27062701 overridden_link_name,
2707- tcx. get_attrs ( did . to_def_id ( ) )
2702+ tcx. get_attrs ( fi . def_id . to_def_id ( ) )
27082703 . iter ( )
27092704 . find ( |at| tcx. sess . check_name ( at, sym:: link_name) )
27102705 . unwrap ( )
@@ -2932,10 +2927,10 @@ impl<'tcx> LateLintPass<'tcx> for ClashingExternDeclarations {
29322927 let tcx = cx. tcx ;
29332928 if let Some ( existing_hid) = self . insert ( tcx, this_fi) {
29342929 let existing_decl_ty = tcx. type_of ( tcx. hir ( ) . local_def_id ( existing_hid) ) ;
2935- let this_decl_ty = tcx. type_of ( tcx . hir ( ) . local_def_id ( this_fi. hir_id ) ) ;
2930+ let this_decl_ty = tcx. type_of ( this_fi. def_id ) ;
29362931 debug ! (
29372932 "ClashingExternDeclarations: Comparing existing {:?}: {:?} to this {:?}: {:?}" ,
2938- existing_hid, existing_decl_ty, this_fi. hir_id , this_decl_ty
2933+ existing_hid, existing_decl_ty, this_fi. def_id , this_decl_ty
29392934 ) ;
29402935 // Check that the declarations match.
29412936 if !Self :: structurally_same_type (
@@ -2957,7 +2952,7 @@ impl<'tcx> LateLintPass<'tcx> for ClashingExternDeclarations {
29572952 // Finally, emit the diagnostic.
29582953 tcx. struct_span_lint_hir (
29592954 CLASHING_EXTERN_DECLARATIONS ,
2960- this_fi. hir_id ,
2955+ this_fi. hir_id ( ) ,
29612956 get_relevant_span ( this_fi) ,
29622957 |lint| {
29632958 let mut expected_str = DiagnosticStyledString :: new ( ) ;
0 commit comments