11use rustc_ast:: ast:: Attribute ;
22use rustc_errors:: Applicability ;
3- use rustc_hir:: ItemKind ;
3+ use rustc_hir:: { Item , ItemKind } ;
44use rustc_lint:: LateContext ;
55
66use clippy_utils:: diagnostics:: { span_lint, span_lint_and_then} ;
@@ -10,13 +10,17 @@ use super::TOO_LONG_FIRST_DOC_PARAGRAPH;
1010
1111pub ( super ) fn check (
1212 cx : & LateContext < ' _ > ,
13+ item : & Item < ' _ > ,
1314 attrs : & [ Attribute ] ,
14- item_kind : ItemKind < ' _ > ,
1515 mut first_paragraph_len : usize ,
16+ check_private_items : bool ,
1617) {
17- if first_paragraph_len <= 100
18+ if !check_private_items && !cx. effective_visibilities . is_exported ( item. owner_id . def_id ) {
19+ return ;
20+ }
21+ if first_paragraph_len <= 200
1822 || !matches ! (
19- item_kind ,
23+ item . kind ,
2024 ItemKind :: Static ( ..)
2125 | ItemKind :: Const ( ..)
2226 | ItemKind :: Fn ( ..)
@@ -32,6 +36,7 @@ pub(super) fn check(
3236 {
3337 return ;
3438 }
39+
3540 let mut spans = Vec :: new ( ) ;
3641 let mut should_suggest_empty_doc = false ;
3742
@@ -42,7 +47,7 @@ pub(super) fn check(
4247 let doc = doc. trim ( ) ;
4348 if spans. len ( ) == 1 {
4449 // We make this suggestion only if the first doc line ends with a punctuation
45- // because if might just need to add an empty line with `///`.
50+ // because it might just need to add an empty line with `///`.
4651 should_suggest_empty_doc = doc. ends_with ( '.' ) || doc. ends_with ( '!' ) || doc. ends_with ( '?' ) ;
4752 }
4853 let len = doc. chars ( ) . count ( ) ;
@@ -68,7 +73,7 @@ pub(super) fn check(
6873 |diag| {
6974 diag. span_suggestion (
7075 new_span,
71- "add" ,
76+ "add an empty line " ,
7277 format ! ( "{snippet}///\n " ) ,
7378 Applicability :: MachineApplicable ,
7479 ) ;
0 commit comments