@@ -310,13 +310,15 @@ declare_clippy_lint! {
310310pub struct DocMarkdown {
311311 valid_idents : FxHashSet < String > ,
312312 in_trait_impl : bool ,
313+ check_private_items : bool ,
313314}
314315
315316impl DocMarkdown {
316- pub fn new ( valid_idents : & [ String ] ) -> Self {
317+ pub fn new ( valid_idents : & [ String ] , check_private_items : bool ) -> Self {
317318 Self {
318319 valid_idents : valid_idents. iter ( ) . cloned ( ) . collect ( ) ,
319320 in_trait_impl : false ,
321+ check_private_items,
320322 }
321323 }
322324}
@@ -349,7 +351,15 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown {
349351 let body = cx. tcx . hir ( ) . body ( body_id) ;
350352
351353 let panic_span = FindPanicUnwrap :: find_span ( cx, cx. tcx . typeck ( item. owner_id ) , body. value ) ;
352- missing_headers:: check ( cx, item. owner_id , sig, headers, Some ( body_id) , panic_span) ;
354+ missing_headers:: check (
355+ cx,
356+ item. owner_id ,
357+ sig,
358+ headers,
359+ Some ( body_id) ,
360+ panic_span,
361+ self . check_private_items ,
362+ ) ;
353363 }
354364 } ,
355365 hir:: ItemKind :: Impl ( impl_) => {
@@ -387,7 +397,7 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown {
387397 } ;
388398 if let hir:: TraitItemKind :: Fn ( ref sig, ..) = item. kind {
389399 if !in_external_macro ( cx. tcx . sess , item. span ) {
390- missing_headers:: check ( cx, item. owner_id , sig, headers, None , None ) ;
400+ missing_headers:: check ( cx, item. owner_id , sig, headers, None , None , self . check_private_items ) ;
391401 }
392402 }
393403 }
@@ -404,7 +414,15 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown {
404414 let body = cx. tcx . hir ( ) . body ( body_id) ;
405415
406416 let panic_span = FindPanicUnwrap :: find_span ( cx, cx. tcx . typeck ( item. owner_id ) , body. value ) ;
407- missing_headers:: check ( cx, item. owner_id , sig, headers, Some ( body_id) , panic_span) ;
417+ missing_headers:: check (
418+ cx,
419+ item. owner_id ,
420+ sig,
421+ headers,
422+ Some ( body_id) ,
423+ panic_span,
424+ self . check_private_items ,
425+ ) ;
408426 }
409427 }
410428}
0 commit comments