-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Add -Z check-cfg-features to enable compile-time checking of features #10408
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @ehuss (or someone else) soon. Please see the contribution instructions for more information. |
412e794
to
03fbb2e
Compare
Nice, thanks! Would you be up for also adding a test for the up-and-coming namespaced features to ensure that works well too? For example having a test that uses |
…tion issues See https://github.com/rust-lang/cargo/runs/5290789288?check_suite_focus=true Where the expected is: --check-cfg 'values(feature, "f_a", "f_b")' But we got: --check-cfg "values(feature, /"f_a/", /"f_b/")"
Done in 4ac4f3d. And just to confirm, in case below
|
I believe so, yes, thanks! |
@bors: r+ |
📌 Commit 4ac4f3d has been approved by |
☀️ Test successful - checks-actions |
Update cargo 8 commits in ea2a21c994ca1e4d4c49412827b3cf4dcb158b1d..d6cdde584a1f15ea086bae922e20fd27f7165431 2022-02-15 04:24:07 +0000 to 2022-02-22 19:55:51 +0000 - Add common profile validation. (rust-lang/cargo#10411) - Add -Z check-cfg-features to enable compile-time checking of features (rust-lang/cargo#10408) - Remove invalid target-specific dependency example. (rust-lang/cargo#10401) - Fix errors in `cargo fetch` usage guide (rust-lang/cargo#10398) - Fix some broken doc links. (rust-lang/cargo#10404) - Implement "artifact dependencies" (RFC-3028) (rust-lang/cargo#9992) - Print executable name on cargo test --no-run rust-lang/cargo#2 (rust-lang/cargo#10346) - Avoid new deprecation warnings from clap 3.1.0 (rust-lang/cargo#10396)
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`
Add support for rustc --check-cfg well known names and values This pull-request add support for `rustc` `--check-cfg` well known names and values. ### What does this PR try to resolve? This pull-request add support for `rustc` `--check-cfg` well known names and values: - `-Z check-cfg-well-known-names`: `--check-cfg names()` well known names - `-Z check-cfg-well-known-values`: `--check-cfg values()` well known values ### How should we test and review this PR? #### Testing `cargo check -Z check-cfg-well-known-names` and `cargo check -Z check-cfg-well-known-values` #### Review This PR contains one commit that split `features_args` into `check_cfg_args`, add the well known support in it, adds call to that new function and add documentation and test for those new flags. ### Additional information This was implemented as two new additional flags because it's most likely that these flags will not be stabilize at the same time and also because some of these flags may become the default. RFC: rust-lang/rfcs#3013 `-Z check-cfg-features`: #10408 `cargo doc` support: #10428
This pull-request implements the "Cargo support" section of RFC 3013: 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 torustc
unstable--check-cfg
command line as--check-cfg=values(feature, ...)
. This enables compile time checking offeature
values in#[cfg]
,cfg!
and#[cfg_attr]
.This new flag currently only affects
rustc
butrustdoc
support will be added as soon as it's support is merged.Note than the intent is that this command line options become the default when stabilizing as suggested in the RFC: