@@ -3,7 +3,8 @@ use rustc_errors::Applicability;
3
3
use rustc_hir:: { Item , ItemKind } ;
4
4
use rustc_lint:: LateContext ;
5
5
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;
7
8
use clippy_utils:: source:: snippet_opt;
8
9
9
10
use super :: TOO_LONG_FIRST_DOC_PARAGRAPH ;
@@ -63,32 +64,28 @@ pub(super) fn check(
63
64
let & [ first_span, .., last_span] = spans. as_slice ( ) else {
64
65
return ;
65
66
} ;
67
+ if is_from_proc_macro ( cx, item) {
68
+ return ;
69
+ }
66
70
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
+ {
78
82
diag. span_suggestion (
79
83
new_span,
80
84
"add an empty line" ,
81
85
format ! ( "{snippet}///\n " ) ,
82
86
Applicability :: MachineApplicable ,
83
87
) ;
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
+ } ,
93
90
) ;
94
91
}
0 commit comments