Skip to content

Commit 2e7ca73

Browse files
Don't emit an error on private doc tests when they're ignored
1 parent 2e2e7de commit 2e7ca73

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/librustdoc/passes/doc_test_lints.rs

+6-10
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::clean;
88
use crate::clean::*;
99
use crate::core::DocContext;
1010
use crate::fold::DocFolder;
11-
use crate::html::markdown::{find_testable_code, ErrorCodes, LangString};
11+
use crate::html::markdown::{find_testable_code, ErrorCodes, Ignore, LangString};
1212
use rustc_session::lint;
1313

1414
pub const CHECK_PRIVATE_ITEMS_DOC_TESTS: Pass = Pass {
@@ -48,15 +48,11 @@ pub(crate) struct Tests {
4848
pub(crate) found_tests: usize,
4949
}
5050

51-
impl Tests {
52-
pub(crate) fn new() -> Tests {
53-
Tests { found_tests: 0 }
54-
}
55-
}
56-
5751
impl crate::doctest::Tester for Tests {
58-
fn add_test(&mut self, _: String, _: LangString, _: usize) {
59-
self.found_tests += 1;
52+
fn add_test(&mut self, _: String, config: LangString, _: usize) {
53+
if config.rust && config.ignore == Ignore::None {
54+
self.found_tests += 1;
55+
}
6056
}
6157
}
6258

@@ -85,7 +81,7 @@ pub fn look_for_tests<'tcx>(cx: &DocContext<'tcx>, dox: &str, item: &Item) {
8581
}
8682
};
8783

88-
let mut tests = Tests::new();
84+
let mut tests = Tests { found_tests: 0 };
8985

9086
find_testable_code(&dox, &mut tests, ErrorCodes::No, false, None);
9187

0 commit comments

Comments
 (0)