@@ -508,8 +508,7 @@ impl MissingDoc {
508
508
fn check_missing_docs_attrs (
509
509
& self ,
510
510
cx : & LateContext < ' _ > ,
511
- id : Option < hir:: HirId > ,
512
- attrs : & [ ast:: Attribute ] ,
511
+ id : hir:: HirId ,
513
512
sp : Span ,
514
513
article : & ' static str ,
515
514
desc : & ' static str ,
@@ -528,12 +527,13 @@ impl MissingDoc {
528
527
// Only check publicly-visible items, using the result from the privacy pass.
529
528
// It's an option so the crate root can also use this function (it doesn't
530
529
// have a `NodeId`).
531
- if let Some ( id ) = id {
530
+ if id != hir :: CRATE_HIR_ID {
532
531
if !cx. access_levels . is_exported ( id) {
533
532
return ;
534
533
}
535
534
}
536
535
536
+ let attrs = cx. tcx . hir ( ) . attrs ( id) ;
537
537
let has_doc = attrs. iter ( ) . any ( |a| has_doc ( cx. sess ( ) , a) ) ;
538
538
if !has_doc {
539
539
cx. struct_span_lint (
@@ -565,7 +565,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
565
565
}
566
566
567
567
fn check_crate ( & mut self , cx : & LateContext < ' _ > , krate : & hir:: Crate < ' _ > ) {
568
- self . check_missing_docs_attrs ( cx, None , & krate . item . attrs , krate. item . span , "the" , "crate" ) ;
568
+ self . check_missing_docs_attrs ( cx, hir :: CRATE_HIR_ID , krate. item . span , "the" , "crate" ) ;
569
569
570
570
for macro_def in krate. exported_macros {
571
571
let has_doc = macro_def. attrs . iter ( ) . any ( |a| has_doc ( cx. sess ( ) , a) ) ;
@@ -622,7 +622,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
622
622
623
623
let ( article, desc) = cx. tcx . article_and_description ( it. def_id . to_def_id ( ) ) ;
624
624
625
- self . check_missing_docs_attrs ( cx, Some ( it. hir_id ( ) ) , & it . attrs , it. span , article, desc) ;
625
+ self . check_missing_docs_attrs ( cx, it. hir_id ( ) , it. span , article, desc) ;
626
626
}
627
627
628
628
fn check_trait_item ( & mut self , cx : & LateContext < ' _ > , trait_item : & hir:: TraitItem < ' _ > ) {
@@ -632,14 +632,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
632
632
633
633
let ( article, desc) = cx. tcx . article_and_description ( trait_item. def_id . to_def_id ( ) ) ;
634
634
635
- self . check_missing_docs_attrs (
636
- cx,
637
- Some ( trait_item. hir_id ( ) ) ,
638
- & trait_item. attrs ,
639
- trait_item. span ,
640
- article,
641
- desc,
642
- ) ;
635
+ self . check_missing_docs_attrs ( cx, trait_item. hir_id ( ) , trait_item. span , article, desc) ;
643
636
}
644
637
645
638
fn check_impl_item ( & mut self , cx : & LateContext < ' _ > , impl_item : & hir:: ImplItem < ' _ > ) {
@@ -649,43 +642,22 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
649
642
}
650
643
651
644
let ( article, desc) = cx. tcx . article_and_description ( impl_item. def_id . to_def_id ( ) ) ;
652
- self . check_missing_docs_attrs (
653
- cx,
654
- Some ( impl_item. hir_id ( ) ) ,
655
- & impl_item. attrs ,
656
- impl_item. span ,
657
- article,
658
- desc,
659
- ) ;
645
+ self . check_missing_docs_attrs ( cx, impl_item. hir_id ( ) , impl_item. span , article, desc) ;
660
646
}
661
647
662
648
fn check_foreign_item ( & mut self , cx : & LateContext < ' _ > , foreign_item : & hir:: ForeignItem < ' _ > ) {
663
649
let ( article, desc) = cx. tcx . article_and_description ( foreign_item. def_id . to_def_id ( ) ) ;
664
- self . check_missing_docs_attrs (
665
- cx,
666
- Some ( foreign_item. hir_id ( ) ) ,
667
- & foreign_item. attrs ,
668
- foreign_item. span ,
669
- article,
670
- desc,
671
- ) ;
650
+ self . check_missing_docs_attrs ( cx, foreign_item. hir_id ( ) , foreign_item. span , article, desc) ;
672
651
}
673
652
674
653
fn check_struct_field ( & mut self , cx : & LateContext < ' _ > , sf : & hir:: StructField < ' _ > ) {
675
654
if !sf. is_positional ( ) {
676
- self . check_missing_docs_attrs (
677
- cx,
678
- Some ( sf. hir_id ) ,
679
- & sf. attrs ,
680
- sf. span ,
681
- "a" ,
682
- "struct field" ,
683
- )
655
+ self . check_missing_docs_attrs ( cx, sf. hir_id , sf. span , "a" , "struct field" )
684
656
}
685
657
}
686
658
687
659
fn check_variant ( & mut self , cx : & LateContext < ' _ > , v : & hir:: Variant < ' _ > ) {
688
- self . check_missing_docs_attrs ( cx, Some ( v. id ) , & v . attrs , v. span , "a" , "variant" ) ;
660
+ self . check_missing_docs_attrs ( cx, v. id , v. span , "a" , "variant" ) ;
689
661
}
690
662
}
691
663
0 commit comments