Skip to content

Commit 992646b

Browse files
committed
Improve rustdoc::private_doc_tests tests
- Ensure standard public items are accepted - Ensure public items not re-exported from private modules are denied
1 parent b0a1a44 commit 992646b

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#![deny(rustdoc::private_doc_tests)]
2+
3+
mod foo {
4+
/// private doc test
5+
///
6+
/// ```
7+
/// assert!(false);
8+
/// ```
9+
//~^^^^^ ERROR documentation test in private item
10+
pub fn bar() {}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
error: documentation test in private item
2+
--> $DIR/private-public-item-doc-test.rs:4:5
3+
|
4+
LL | / /// private doc test
5+
LL | | ///
6+
LL | | /// ```
7+
LL | | /// assert!(false);
8+
LL | | /// ```
9+
| |___________^
10+
|
11+
note: the lint level is defined here
12+
--> $DIR/private-public-item-doc-test.rs:1:9
13+
|
14+
LL | #![deny(rustdoc::private_doc_tests)]
15+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
16+
17+
error: aborting due to previous error
18+

src/test/rustdoc-ui/public-reexported-item-doc-test.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
#![deny(rustdoc::private_doc_tests)]
44

5-
mod foo {
5+
pub fn foo() {}
6+
7+
mod private {
68
/// re-exported doc test
79
///
810
/// ```
@@ -11,4 +13,4 @@ mod foo {
1113
pub fn bar() {}
1214
}
1315

14-
pub use foo::bar;
16+
pub use private::bar;

0 commit comments

Comments
 (0)