1
1
//! This pass is overloaded and runs two different lints.
2
2
//!
3
- //! - MISSING_DOC_CODE_EXAMPLES: this looks for public items missing doc-tests
4
- //! - PRIVATE_DOC_TESTS: this looks for private items with doc-tests.
3
+ //! - MISSING_DOC_CODE_EXAMPLES: this lint is **UNSTABLE** and looks for public items missing doc-tests
4
+ //! - PRIVATE_DOC_TESTS: this lint is **STABLE** and looks for private items with doc-tests.
5
5
6
6
use super :: { span_of_attrs, Pass } ;
7
7
use crate :: clean;
@@ -89,7 +89,9 @@ pub fn look_for_tests<'tcx>(cx: &DocContext<'tcx>, dox: &str, item: &Item) {
89
89
90
90
find_testable_code ( & dox, & mut tests, ErrorCodes :: No , false , None ) ;
91
91
92
- if tests. found_tests == 0 {
92
+ if tests. found_tests == 0
93
+ && rustc_feature:: UnstableFeatures :: from_environment ( ) . is_nightly_build ( )
94
+ {
93
95
if should_have_doc_example ( & item. inner ) {
94
96
debug ! ( "reporting error for {:?} (hir_id={:?})" , item, hir_id) ;
95
97
let sp = span_of_attrs ( & item. attrs ) . unwrap_or ( item. source . span ( ) ) ;
@@ -100,9 +102,7 @@ pub fn look_for_tests<'tcx>(cx: &DocContext<'tcx>, dox: &str, item: &Item) {
100
102
|lint| lint. build ( "missing code example in this documentation" ) . emit ( ) ,
101
103
) ;
102
104
}
103
- } else if rustc_feature:: UnstableFeatures :: from_environment ( ) . is_nightly_build ( )
104
- && tests. found_tests > 0
105
- && !cx. renderinfo . borrow ( ) . access_levels . is_public ( item. def_id )
105
+ } else if tests. found_tests > 0 && !cx. renderinfo . borrow ( ) . access_levels . is_public ( item. def_id )
106
106
{
107
107
cx. tcx . struct_span_lint_hir (
108
108
lint:: builtin:: PRIVATE_DOC_TESTS ,
0 commit comments