@@ -3,7 +3,8 @@ use rustc_errors::Applicability;
33use rustc_hir:: { Item , ItemKind } ;
44use rustc_lint:: LateContext ;
55
6- use clippy_utils:: diagnostics:: { span_lint, span_lint_and_then} ;
6+ use clippy_utils:: diagnostics:: span_lint_and_then;
7+ use clippy_utils:: is_from_proc_macro;
78use clippy_utils:: source:: snippet_opt;
89
910use super :: TOO_LONG_FIRST_DOC_PARAGRAPH ;
@@ -63,32 +64,28 @@ pub(super) fn check(
6364 let & [ first_span, .., last_span] = spans. as_slice ( ) else {
6465 return ;
6566 } ;
67+ if is_from_proc_macro ( cx, item) {
68+ return ;
69+ }
6670
67- if should_suggest_empty_doc
68- && let Some ( second_span ) = spans . get ( 1 )
69- && let new_span = first_span . with_hi ( second_span . lo ( ) ) . with_lo ( first_span . hi ( ) )
70- && let Some ( snippet ) = snippet_opt ( cx , new_span )
71- {
72- span_lint_and_then (
73- cx ,
74- TOO_LONG_FIRST_DOC_PARAGRAPH ,
75- first_span. with_hi ( last_span . lo ( ) ) ,
76- "first doc comment paragraph is too long" ,
77- |diag| {
71+ span_lint_and_then (
72+ cx ,
73+ TOO_LONG_FIRST_DOC_PARAGRAPH ,
74+ first_span . with_hi ( last_span . lo ( ) ) ,
75+ "first doc comment paragraph is too long" ,
76+ |diag| {
77+ if should_suggest_empty_doc
78+ && let Some ( second_span ) = spans . get ( 1 )
79+ && let new_span = first_span. with_hi ( second_span . lo ( ) ) . with_lo ( first_span . hi ( ) )
80+ && let Some ( snippet ) = snippet_opt ( cx , new_span )
81+ {
7882 diag. span_suggestion (
7983 new_span,
8084 "add an empty line" ,
8185 format ! ( "{snippet}///\n " ) ,
8286 Applicability :: MachineApplicable ,
8387 ) ;
84- } ,
85- ) ;
86- return ;
87- }
88- span_lint (
89- cx,
90- TOO_LONG_FIRST_DOC_PARAGRAPH ,
91- first_span. with_hi ( last_span. lo ( ) ) ,
92- "first doc comment paragraph is too long" ,
88+ }
89+ } ,
9390 ) ;
9491}
0 commit comments