-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #62213 - QuietMisdreavus:cfg-doctest, r=GuillaumeGomez
rustdoc: set cfg(doctest) when collecting doctests Note: This PR builds on top of #61199; only the last commit is specific to this PR. As discussed in #61199, we want the ability to isolate items to only when rustdoc is collecting doctests, but we can't use `cfg(test)` because of libcore's `#![cfg(not(test))]`. This PR proposes a new cfg flag, `cfg(doctest)`, specific to this situation, rather than reusing an existing flag. I've isolated it behind a feature gate so that we can contain the effects to nightly only. (A stable workaround that can be used in lieu of `#[cfg(doctest)]` is `#[cfg(rustdoc)] #[doc(hidden)]`, at least once #61351 lands.) Tracking issue: #62210
- Loading branch information
Showing
9 changed files
with
78 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
|
||
running 1 test | ||
test $DIR/cfg-test.rs - Foo (line 18) ... ok | ||
running 2 tests | ||
test $DIR/cfg-test.rs - Bar (line 28) ... ok | ||
test $DIR/cfg-test.rs - Foo (line 20) ... ok | ||
|
||
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out | ||
test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#![feature(cfg_doctest)] | ||
|
||
// @!has cfg_doctest/struct.SomeStruct.html | ||
// @!has cfg_doctest/index.html '//a/@href' 'struct.SomeStruct.html' | ||
|
||
/// Sneaky, this isn't actually part of docs. | ||
#[cfg(doctest)] | ||
pub struct SomeStruct; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#[cfg(doctest)] //~ ERROR | ||
pub struct SomeStruct; | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
error[E0658]: `cfg(doctest)` is experimental and subject to change | ||
--> $DIR/feature-gate-cfg_doctest.rs:1:7 | ||
| | ||
LL | #[cfg(doctest)] | ||
| ^^^^^^^ | ||
| | ||
= note: for more information, see https://github.com/rust-lang/rust/issues/62210 | ||
= help: add #![feature(cfg_doctest)] to the crate attributes to enable | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0658`. |