Skip to content

Commit

Permalink
Improve rustdoc::private_doc_tests tests
Browse files Browse the repository at this point in the history
- Ensure standard public items are accepted
- Ensure public items not re-exported from private modules are denied
  • Loading branch information
avitex committed Dec 28, 2021
1 parent b0a1a44 commit 992646b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
11 changes: 11 additions & 0 deletions src/test/rustdoc-ui/private-public-item-doc-test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#![deny(rustdoc::private_doc_tests)]

mod foo {
/// private doc test
///
/// ```
/// assert!(false);
/// ```
//~^^^^^ ERROR documentation test in private item
pub fn bar() {}
}
18 changes: 18 additions & 0 deletions src/test/rustdoc-ui/private-public-item-doc-test.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
error: documentation test in private item
--> $DIR/private-public-item-doc-test.rs:4:5
|
LL | / /// private doc test
LL | | ///
LL | | /// ```
LL | | /// assert!(false);
LL | | /// ```
| |___________^
|
note: the lint level is defined here
--> $DIR/private-public-item-doc-test.rs:1:9
|
LL | #![deny(rustdoc::private_doc_tests)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

6 changes: 4 additions & 2 deletions src/test/rustdoc-ui/public-reexported-item-doc-test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

#![deny(rustdoc::private_doc_tests)]

mod foo {
pub fn foo() {}

mod private {
/// re-exported doc test
///
/// ```
Expand All @@ -11,4 +13,4 @@ mod foo {
pub fn bar() {}
}

pub use foo::bar;
pub use private::bar;

0 comments on commit 992646b

Please sign in to comment.