@@ -38,7 +38,7 @@ use rustc_feature::{deprecated_attributes, AttributeGate, AttributeTemplate, Att
3838use rustc_feature:: { GateIssue , Stability } ;
3939use rustc_hir as hir;
4040use rustc_hir:: def:: { DefKind , Res } ;
41- use rustc_hir:: def_id:: { DefId , LocalDefId , LocalDefIdSet } ;
41+ use rustc_hir:: def_id:: { DefId , LocalDefId , LocalDefIdSet , CRATE_DEF_ID } ;
4242use rustc_hir:: { ForeignItemKind , GenericParamKind , PatKind } ;
4343use rustc_hir:: { HirId , Node } ;
4444use rustc_index:: vec:: Idx ;
@@ -511,7 +511,7 @@ impl MissingDoc {
511511 fn check_missing_docs_attrs (
512512 & self ,
513513 cx : & LateContext < ' _ > ,
514- id : hir :: HirId ,
514+ def_id : LocalDefId ,
515515 sp : Span ,
516516 article : & ' static str ,
517517 desc : & ' static str ,
@@ -530,13 +530,13 @@ impl MissingDoc {
530530 // Only check publicly-visible items, using the result from the privacy pass.
531531 // It's an option so the crate root can also use this function (it doesn't
532532 // have a `NodeId`).
533- if id != hir :: CRATE_HIR_ID {
534- if !cx. access_levels . is_exported ( id ) {
533+ if def_id != CRATE_DEF_ID {
534+ if !cx. access_levels . is_exported ( def_id ) {
535535 return ;
536536 }
537537 }
538538
539- let attrs = cx. tcx . hir ( ) . attrs ( id ) ;
539+ let attrs = cx. tcx . get_attrs ( def_id . to_def_id ( ) ) ;
540540 let has_doc = attrs. iter ( ) . any ( |a| has_doc ( cx. sess ( ) , a) ) ;
541541 if !has_doc {
542542 cx. struct_span_lint (
@@ -568,12 +568,12 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
568568 }
569569
570570 fn check_crate ( & mut self , cx : & LateContext < ' _ > , krate : & hir:: Crate < ' _ > ) {
571- self . check_missing_docs_attrs ( cx, hir :: CRATE_HIR_ID , krate. module ( ) . inner , "the" , "crate" ) ;
571+ self . check_missing_docs_attrs ( cx, CRATE_DEF_ID , krate. module ( ) . inner , "the" , "crate" ) ;
572572
573573 for macro_def in krate. exported_macros ( ) {
574574 // Non exported macros should be skipped, since `missing_docs` only
575575 // applies to externally visible items.
576- if !cx. access_levels . is_exported ( macro_def. hir_id ( ) ) {
576+ if !cx. access_levels . is_exported ( macro_def. def_id ) {
577577 continue ;
578578 }
579579
@@ -632,7 +632,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
632632
633633 let ( article, desc) = cx. tcx . article_and_description ( it. def_id . to_def_id ( ) ) ;
634634
635- self . check_missing_docs_attrs ( cx, it. hir_id ( ) , it. span , article, desc) ;
635+ self . check_missing_docs_attrs ( cx, it. def_id , it. span , article, desc) ;
636636 }
637637
638638 fn check_trait_item ( & mut self , cx : & LateContext < ' _ > , trait_item : & hir:: TraitItem < ' _ > ) {
@@ -642,7 +642,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
642642
643643 let ( article, desc) = cx. tcx . article_and_description ( trait_item. def_id . to_def_id ( ) ) ;
644644
645- self . check_missing_docs_attrs ( cx, trait_item. hir_id ( ) , trait_item. span , article, desc) ;
645+ self . check_missing_docs_attrs ( cx, trait_item. def_id , trait_item. span , article, desc) ;
646646 }
647647
648648 fn check_impl_item ( & mut self , cx : & LateContext < ' _ > , impl_item : & hir:: ImplItem < ' _ > ) {
@@ -652,22 +652,23 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
652652 }
653653
654654 let ( article, desc) = cx. tcx . article_and_description ( impl_item. def_id . to_def_id ( ) ) ;
655- self . check_missing_docs_attrs ( cx, impl_item. hir_id ( ) , impl_item. span , article, desc) ;
655+ self . check_missing_docs_attrs ( cx, impl_item. def_id , impl_item. span , article, desc) ;
656656 }
657657
658658 fn check_foreign_item ( & mut self , cx : & LateContext < ' _ > , foreign_item : & hir:: ForeignItem < ' _ > ) {
659659 let ( article, desc) = cx. tcx . article_and_description ( foreign_item. def_id . to_def_id ( ) ) ;
660- self . check_missing_docs_attrs ( cx, foreign_item. hir_id ( ) , foreign_item. span , article, desc) ;
660+ self . check_missing_docs_attrs ( cx, foreign_item. def_id , foreign_item. span , article, desc) ;
661661 }
662662
663663 fn check_field_def ( & mut self , cx : & LateContext < ' _ > , sf : & hir:: FieldDef < ' _ > ) {
664664 if !sf. is_positional ( ) {
665- self . check_missing_docs_attrs ( cx, sf. hir_id , sf. span , "a" , "struct field" )
665+ let def_id = cx. tcx . hir ( ) . local_def_id ( sf. hir_id ) ;
666+ self . check_missing_docs_attrs ( cx, def_id, sf. span , "a" , "struct field" )
666667 }
667668 }
668669
669670 fn check_variant ( & mut self , cx : & LateContext < ' _ > , v : & hir:: Variant < ' _ > ) {
670- self . check_missing_docs_attrs ( cx, v. id , v. span , "a" , "variant" ) ;
671+ self . check_missing_docs_attrs ( cx, cx . tcx . hir ( ) . local_def_id ( v. id ) , v. span , "a" , "variant" ) ;
671672 }
672673}
673674
@@ -709,7 +710,7 @@ declare_lint_pass!(MissingCopyImplementations => [MISSING_COPY_IMPLEMENTATIONS])
709710
710711impl < ' tcx > LateLintPass < ' tcx > for MissingCopyImplementations {
711712 fn check_item ( & mut self , cx : & LateContext < ' _ > , item : & hir:: Item < ' _ > ) {
712- if !cx. access_levels . is_reachable ( item. hir_id ( ) ) {
713+ if !cx. access_levels . is_reachable ( item. def_id ) {
713714 return ;
714715 }
715716 let ( def, ty) = match item. kind {
@@ -796,7 +797,7 @@ impl_lint_pass!(MissingDebugImplementations => [MISSING_DEBUG_IMPLEMENTATIONS]);
796797
797798impl < ' tcx > LateLintPass < ' tcx > for MissingDebugImplementations {
798799 fn check_item ( & mut self , cx : & LateContext < ' _ > , item : & hir:: Item < ' _ > ) {
799- if !cx. access_levels . is_reachable ( item. hir_id ( ) ) {
800+ if !cx. access_levels . is_reachable ( item. def_id ) {
800801 return ;
801802 }
802803
@@ -1314,14 +1315,14 @@ impl UnreachablePub {
13141315 & self ,
13151316 cx : & LateContext < ' _ > ,
13161317 what : & str ,
1317- id : hir :: HirId ,
1318+ def_id : LocalDefId ,
13181319 vis : & hir:: Visibility < ' _ > ,
13191320 span : Span ,
13201321 exportable : bool ,
13211322 ) {
13221323 let mut applicability = Applicability :: MachineApplicable ;
13231324 match vis. node {
1324- hir:: VisibilityKind :: Public if !cx. access_levels . is_reachable ( id ) => {
1325+ hir:: VisibilityKind :: Public if !cx. access_levels . is_reachable ( def_id ) => {
13251326 if span. from_expansion ( ) {
13261327 applicability = Applicability :: MaybeIncorrect ;
13271328 }
@@ -1354,26 +1355,27 @@ impl UnreachablePub {
13541355
13551356impl < ' tcx > LateLintPass < ' tcx > for UnreachablePub {
13561357 fn check_item ( & mut self , cx : & LateContext < ' _ > , item : & hir:: Item < ' _ > ) {
1357- self . perform_lint ( cx, "item" , item. hir_id ( ) , & item. vis , item. span , true ) ;
1358+ self . perform_lint ( cx, "item" , item. def_id , & item. vis , item. span , true ) ;
13581359 }
13591360
13601361 fn check_foreign_item ( & mut self , cx : & LateContext < ' _ > , foreign_item : & hir:: ForeignItem < ' tcx > ) {
13611362 self . perform_lint (
13621363 cx,
13631364 "item" ,
1364- foreign_item. hir_id ( ) ,
1365+ foreign_item. def_id ,
13651366 & foreign_item. vis ,
13661367 foreign_item. span ,
13671368 true ,
13681369 ) ;
13691370 }
13701371
13711372 fn check_field_def ( & mut self , cx : & LateContext < ' _ > , field : & hir:: FieldDef < ' _ > ) {
1372- self . perform_lint ( cx, "field" , field. hir_id , & field. vis , field. span , false ) ;
1373+ let def_id = cx. tcx . hir ( ) . local_def_id ( field. hir_id ) ;
1374+ self . perform_lint ( cx, "field" , def_id, & field. vis , field. span , false ) ;
13731375 }
13741376
13751377 fn check_impl_item ( & mut self , cx : & LateContext < ' _ > , impl_item : & hir:: ImplItem < ' _ > ) {
1376- self . perform_lint ( cx, "item" , impl_item. hir_id ( ) , & impl_item. vis , impl_item. span , false ) ;
1378+ self . perform_lint ( cx, "item" , impl_item. def_id , & impl_item. vis , impl_item. span , false ) ;
13771379 }
13781380}
13791381
0 commit comments