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

Wire up unstable rustc --check-cfg to rustdoc #94154

Merged
merged 2 commits into from
Feb 25, 2022

Conversation

Urgau
Copy link
Member

@Urgau Urgau commented Feb 19, 2022

This pull-request wire up the new unstable --check-cfg option from rustc to rustdoc as requested in the pull-request that introduce --check-cfg.

The motivation was describe in the original PR by @jyn514 who wrote #89346 (comment):

add plumbing to pass --check-cfg from rustdoc (do we want this one?)

It would be useful, I think, it catches issues like cfg(doctst) or something (and in general I would like expansion to match rustc as closely as possible).

@rust-highfive
Copy link
Collaborator

r? @GuillaumeGomez

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 19, 2022
@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Feb 19, 2022
@Urgau
Copy link
Member Author

Urgau commented Feb 19, 2022

This was a weird! Simply doing this ./x.py test --stage 1 src/test/rustdoc-ui/check-cfg-test.rs made the test pass but not on CI (what ?).

I had to manually had some extra normalizations (based on other rustdoc test) to make it fail locally. I think it will now pass on CI as well.

// normalize-stderr-test: "src/test/rustdoc-ui" -> "$$DIR"
// normalize-stdout-test: "src/test/rustdoc-ui" -> "$$DIR"

@GuillaumeGomez
Copy link
Member

GuillaumeGomez commented Feb 20, 2022

Can you also add it into the rustdoc book please?

Also cc @petrochenkov @camelid

@camelid
Copy link
Member

camelid commented Feb 20, 2022

I don't have context for this change, but I don't think it's really necessary to discuss it now since it's unstable?

bors added a commit to rust-lang/cargo that referenced this pull request Feb 22, 2022
Add -Z check-cfg-features to enable compile-time checking of features

This pull-request implements the "[Cargo support](https://rust-lang.github.io/rfcs/3013-conditional-compilation-checking.html#cargo-support)" section of [RFC 3013: Checking conditional compilation at compile time](https://rust-lang.github.io/rfcs/3013-conditional-compilation-checking.html#checking-conditional-compilation-at-compile-time).

The support is added in the form of an new unstable flags: `-Z check-cfg-features` that pass all possible features of a package to
`rustc` unstable `--check-cfg` command line as `--check-cfg=values(feature, ...)`. This enables compile time checking of `feature` values in `#[cfg]`, `cfg!` and `#[cfg_attr]`.

This new flag currently only affects `rustc` but `rustdoc` support will be added as soon as [it's support](rust-lang/rust#94154) is merged.

Note than the intent is that this command line options become the default when stabilizing as suggested in the RFC:
> [..] it seems uncontroversial for Cargo to enable checking for feature = "..." values immediately [..]
@GuillaumeGomez
Copy link
Member

Thanks!

@bors: r+

@bors
Copy link
Contributor

bors commented Feb 25, 2022

📌 Commit a31ae15 has been approved by GuillaumeGomez

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 25, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 25, 2022
…eGomez

Wire up unstable rustc --check-cfg to rustdoc

This pull-request wire up the new unstable `--check-cfg` option from `rustc` to `rustdoc` as [requested](rust-lang#93915 (comment)) in the [pull-request](rust-lang#93915) that introduce `--check-cfg`.

The motivation was describe in the original PR by `@jyn514` who wrote rust-lang#89346 (comment):
> > add plumbing to pass --check-cfg from rustdoc (do we want this one?)
>
> It would be useful, I think, it catches issues like cfg(doctst) or something (and in general I would like expansion to match rustc as closely as possible).
This was referenced Feb 25, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 25, 2022
…askrgr

Rollup of 4 pull requests

Successful merges:

 - rust-lang#93850 (Don't ICE when an extern static is too big for the current architecture)
 - rust-lang#94154 (Wire up unstable rustc --check-cfg to rustdoc)
 - rust-lang#94353 (Fix debug_assert in unused lint pass)
 - rust-lang#94366 (Add missing item to release notes)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit ed202b8 into rust-lang:master Feb 25, 2022
@rustbot rustbot added this to the 1.61.0 milestone Feb 25, 2022
bors added a commit to rust-lang/cargo that referenced this pull request Feb 27, 2022
Add -Z check-cfg-features support for rustdoc

This PR is a follow to #10408 where support for compile-time checking of features was implemented for `rustc`.

At the time `rustdoc` support wasn't yet merged, but now that it has been [merged](rust-lang/rust#94154), this pull-request add support for it in the `doc` and `test --doc` (doctest) mode.

r? `@alexcrichton`
@Urgau Urgau deleted the rustdoc-check-cfg branch May 5, 2023 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants