@@ -738,52 +738,33 @@ impl EarlyLintPass for DeprecatedAttr {
738
738
}
739
739
}
740
740
741
- trait UnusedDocCommentExt {
742
- fn warn_if_doc (
743
- & self ,
744
- cx : & EarlyContext < ' _ > ,
745
- node_span : Span ,
746
- node_kind : & str ,
747
- attrs : & [ ast:: Attribute ] ,
748
- ) ;
749
- }
741
+ fn warn_if_doc ( cx : & EarlyContext < ' _ > , node_span : Span , node_kind : & str , attrs : & [ ast:: Attribute ] ) {
742
+ let mut attrs = attrs. into_iter ( ) . peekable ( ) ;
750
743
751
- impl UnusedDocCommentExt for UnusedDocComment {
752
- fn warn_if_doc (
753
- & self ,
754
- cx : & EarlyContext < ' _ > ,
755
- node_span : Span ,
756
- node_kind : & str ,
757
- attrs : & [ ast:: Attribute ] ,
758
- ) {
759
- let mut attrs = attrs. into_iter ( ) . peekable ( ) ;
760
-
761
- // Accumulate a single span for sugared doc comments.
762
- let mut sugared_span: Option < Span > = None ;
744
+ // Accumulate a single span for sugared doc comments.
745
+ let mut sugared_span: Option < Span > = None ;
763
746
764
- while let Some ( attr) = attrs. next ( ) {
765
- if attr. is_doc_comment ( ) {
766
- sugared_span = Some (
767
- sugared_span. map_or_else ( || attr. span , |span| span. with_hi ( attr. span . hi ( ) ) ) ,
768
- ) ;
769
- }
747
+ while let Some ( attr) = attrs. next ( ) {
748
+ if attr. is_doc_comment ( ) {
749
+ sugared_span =
750
+ Some ( sugared_span. map_or_else ( || attr. span , |span| span. with_hi ( attr. span . hi ( ) ) ) ) ;
751
+ }
770
752
771
- if attrs. peek ( ) . map ( |next_attr| next_attr. is_doc_comment ( ) ) . unwrap_or_default ( ) {
772
- continue ;
773
- }
753
+ if attrs. peek ( ) . map ( |next_attr| next_attr. is_doc_comment ( ) ) . unwrap_or_default ( ) {
754
+ continue ;
755
+ }
774
756
775
- let span = sugared_span. take ( ) . unwrap_or_else ( || attr. span ) ;
757
+ let span = sugared_span. take ( ) . unwrap_or_else ( || attr. span ) ;
776
758
777
- if attr. is_doc_comment ( ) || attr. check_name ( sym:: doc) {
778
- cx. struct_span_lint ( UNUSED_DOC_COMMENTS , span, |lint| {
779
- let mut err = lint. build ( "unused doc comment" ) ;
780
- err. span_label (
781
- node_span,
782
- format ! ( "rustdoc does not generate documentation for {}" , node_kind) ,
783
- ) ;
784
- err. emit ( ) ;
785
- } ) ;
786
- }
759
+ if attr. is_doc_comment ( ) || attr. check_name ( sym:: doc) {
760
+ cx. struct_span_lint ( UNUSED_DOC_COMMENTS , span, |lint| {
761
+ let mut err = lint. build ( "unused doc comment" ) ;
762
+ err. span_label (
763
+ node_span,
764
+ format ! ( "rustdoc does not generate documentation for {}" , node_kind) ,
765
+ ) ;
766
+ err. emit ( ) ;
767
+ } ) ;
787
768
}
788
769
}
789
770
}
@@ -797,16 +778,16 @@ impl EarlyLintPass for UnusedDocComment {
797
778
ast:: StmtKind :: Semi ( ..) | ast:: StmtKind :: Expr ( ..) | ast:: StmtKind :: Mac ( ..) => return ,
798
779
} ;
799
780
800
- self . warn_if_doc ( cx, stmt. span , kind, stmt. kind . attrs ( ) ) ;
781
+ warn_if_doc ( cx, stmt. span , kind, stmt. kind . attrs ( ) ) ;
801
782
}
802
783
803
784
fn check_arm ( & mut self , cx : & EarlyContext < ' _ > , arm : & ast:: Arm ) {
804
785
let arm_span = arm. pat . span . with_hi ( arm. body . span . hi ( ) ) ;
805
- self . warn_if_doc ( cx, arm_span, "match arms" , & arm. attrs ) ;
786
+ warn_if_doc ( cx, arm_span, "match arms" , & arm. attrs ) ;
806
787
}
807
788
808
789
fn check_expr ( & mut self , cx : & EarlyContext < ' _ > , expr : & ast:: Expr ) {
809
- self . warn_if_doc ( cx, expr. span , "expressions" , & expr. attrs ) ;
790
+ warn_if_doc ( cx, expr. span , "expressions" , & expr. attrs ) ;
810
791
}
811
792
}
812
793
0 commit comments