Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracking issue for cfg(doctest) #62210

Closed
QuietMisdreavus opened this issue Jun 28, 2019 · 3 comments · Fixed by #63803
Closed

Tracking issue for cfg(doctest) #62210

QuietMisdreavus opened this issue Jun 28, 2019 · 3 comments · Fixed by #63803
Labels
A-doctests Area: Documentation tests, run by rustdoc C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@QuietMisdreavus
Copy link
Member

QuietMisdreavus commented Jun 28, 2019

This feature allows you to restrict items to only be compiled when rustdoc is collecting doctests. This allows you to isolate certain doctests that will be tested, but not shown in documentation - for example, if you need to use compile_fail, or if you're testing the samples in your README file.

We had previously set cfg(test) when collecting doctests, starting in #59940, but this caused issues with libcore that caused all its doctests to be ignored, so that was reverted in #61199. This feature is the replacement for that, currently unstable while we ensure the semantics. The PR where it was posted is #62213.

@QuietMisdreavus QuietMisdreavus added C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-doctests Area: Documentation tests, run by rustdoc labels Jun 28, 2019
Centril added a commit to Centril/rust that referenced this issue Jul 7, 2019
…laumeGomez

rustdoc: set cfg(doctest) when collecting doctests

Note: This PR builds on top of rust-lang#61199; only the last commit is specific to this PR.

As discussed in rust-lang#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 rust-lang#61351 lands.)

Tracking issue: rust-lang#62210
@RalfJung
Copy link
Member

Is there a decision whether this is considered misuse of cfg(test) by libcore (so libcore should be fixed, and then doctest collection can set test again), or whether this has been behavior on stable for way too long and hence cannot be broken?

To my knowledge, the revert happened so that we would have time to have that discussion. You can't discuss whether a change in behavior (of cfg(test)) should happen after doing it.

@RalfJung
Copy link
Member

Also see @Mark-Simulacrum's statement at #63201 (comment):

I agree that the discussion @RalfJung notes should happen prior to landing stabilization.

@dp289m
Copy link

dp289m commented Sep 11, 2020

sudo amazon-linux-extras install -y rust1
wget https://github.com/xiph/rav1e/archive/v0.3.4.tar.gz -O rav1e-v0.3.4.tar.gz
tar xvf rav1e-v0.3.4.tar.gz 
cd rav1e-v0.3.4.tar.gz
cargo install cargo-c

...
error[E0658]: cfg(doctest) is experimental and subject to change
...
build failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-doctests Area: Documentation tests, run by rustdoc C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
3 participants