Rollup merge of #76642 - GuillaumeGomez:ignored-private-doc-test, r=jyn514
Do not lint ignored private doc tests Fixes #76457. r? @ehuss
This commit is contained in:
commit
ece688bae9
@ -8,7 +8,7 @@ use crate::clean;
|
|||||||
use crate::clean::*;
|
use crate::clean::*;
|
||||||
use crate::core::DocContext;
|
use crate::core::DocContext;
|
||||||
use crate::fold::DocFolder;
|
use crate::fold::DocFolder;
|
||||||
use crate::html::markdown::{find_testable_code, ErrorCodes, LangString};
|
use crate::html::markdown::{find_testable_code, ErrorCodes, Ignore, LangString};
|
||||||
use rustc_session::lint;
|
use rustc_session::lint;
|
||||||
|
|
||||||
pub const CHECK_PRIVATE_ITEMS_DOC_TESTS: Pass = Pass {
|
pub const CHECK_PRIVATE_ITEMS_DOC_TESTS: Pass = Pass {
|
||||||
@ -48,15 +48,11 @@ pub(crate) struct Tests {
|
|||||||
pub(crate) found_tests: usize,
|
pub(crate) found_tests: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Tests {
|
|
||||||
pub(crate) fn new() -> Tests {
|
|
||||||
Tests { found_tests: 0 }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl crate::doctest::Tester for Tests {
|
impl crate::doctest::Tester for Tests {
|
||||||
fn add_test(&mut self, _: String, _: LangString, _: usize) {
|
fn add_test(&mut self, _: String, config: LangString, _: usize) {
|
||||||
self.found_tests += 1;
|
if config.rust && config.ignore == Ignore::None {
|
||||||
|
self.found_tests += 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +81,7 @@ pub fn look_for_tests<'tcx>(cx: &DocContext<'tcx>, dox: &str, item: &Item) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut tests = Tests::new();
|
let mut tests = Tests { found_tests: 0 };
|
||||||
|
|
||||||
find_testable_code(&dox, &mut tests, ErrorCodes::No, false, None);
|
find_testable_code(&dox, &mut tests, ErrorCodes::No, false, None);
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
+-------------------------------------+------------+------------+------------+------------+
|
+-------------------------------------+------------+------------+------------+------------+
|
||||||
| File | Documented | Percentage | Examples | Percentage |
|
| File | Documented | Percentage | Examples | Percentage |
|
||||||
+-------------------------------------+------------+------------+------------+------------+
|
+-------------------------------------+------------+------------+------------+------------+
|
||||||
| ...tdoc-ui/coverage/doc-examples.rs | 4 | 100.0% | 2 | 50.0% |
|
| ...tdoc-ui/coverage/doc-examples.rs | 4 | 100.0% | 1 | 25.0% |
|
||||||
+-------------------------------------+------------+------------+------------+------------+
|
+-------------------------------------+------------+------------+------------+------------+
|
||||||
| Total | 4 | 100.0% | 2 | 50.0% |
|
| Total | 4 | 100.0% | 1 | 25.0% |
|
||||||
+-------------------------------------+------------+------------+------------+------------+
|
+-------------------------------------+------------+------------+------------+------------+
|
||||||
|
12
src/test/rustdoc-ui/private-doc-test.rs
Normal file
12
src/test/rustdoc-ui/private-doc-test.rs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
// check-pass
|
||||||
|
|
||||||
|
#![deny(private_doc_tests)]
|
||||||
|
|
||||||
|
mod foo {
|
||||||
|
/// private doc test
|
||||||
|
///
|
||||||
|
/// ```ignore (used for testing ignored doc tests)
|
||||||
|
/// assert!(false);
|
||||||
|
/// ```
|
||||||
|
fn bar() {}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user