@@ -53,20 +53,22 @@ impl crate::doctest::Tester for Tests {
53
53
}
54
54
55
55
crate fn should_have_doc_example ( cx : & DocContext < ' _ > , item : & clean:: Item ) -> bool {
56
- if matches ! (
57
- * item. kind,
58
- clean:: StructFieldItem ( _)
59
- | clean:: VariantItem ( _)
60
- | clean:: AssocConstItem ( _, _)
61
- | clean:: AssocTypeItem ( _, _)
62
- | clean:: TypedefItem ( _, _)
63
- | clean:: StaticItem ( _)
64
- | clean:: ConstantItem ( _)
65
- | clean:: ExternCrateItem ( _, _)
66
- | clean:: ImportItem ( _)
67
- | clean:: PrimitiveItem ( _)
68
- | clean:: KeywordItem ( _)
69
- ) {
56
+ if !cx. renderinfo . borrow ( ) . access_levels . is_public ( item. def_id )
57
+ || matches ! (
58
+ * item. kind,
59
+ clean:: StructFieldItem ( _)
60
+ | clean:: VariantItem ( _)
61
+ | clean:: AssocConstItem ( _, _)
62
+ | clean:: AssocTypeItem ( _, _)
63
+ | clean:: TypedefItem ( _, _)
64
+ | clean:: StaticItem ( _)
65
+ | clean:: ConstantItem ( _)
66
+ | clean:: ExternCrateItem ( _, _)
67
+ | clean:: ImportItem ( _)
68
+ | clean:: PrimitiveItem ( _)
69
+ | clean:: KeywordItem ( _)
70
+ )
71
+ {
70
72
return false ;
71
73
}
72
74
let hir_id = cx. tcx . hir ( ) . local_def_id_to_hir_id ( item. def_id . expect_local ( ) ) ;
@@ -93,9 +95,7 @@ crate fn look_for_tests<'tcx>(cx: &DocContext<'tcx>, dox: &str, item: &Item) {
93
95
find_testable_code ( & dox, & mut tests, ErrorCodes :: No , false , None ) ;
94
96
95
97
if tests. found_tests == 0 && cx. tcx . sess . is_nightly_build ( ) {
96
- if cx. renderinfo . borrow ( ) . access_levels . is_public ( item. def_id )
97
- && should_have_doc_example ( cx, & item)
98
- {
98
+ if should_have_doc_example ( cx, & item) {
99
99
debug ! ( "reporting error for {:?} (hir_id={:?})" , item, hir_id) ;
100
100
let sp = span_of_attrs ( & item. attrs ) . unwrap_or ( item. source . span ( ) ) ;
101
101
cx. tcx . struct_span_lint_hir (
0 commit comments