-
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 support for rustc --check-cfg well known names and values #10486
Conversation
r? @ehuss (rust-highfive has picked a reviewer for you, use r? to override) |
a0ed44c
to
02cd944
Compare
Thanks! I might miss some design discussions of landing BTW, could you help open one tracking issue for |
You didn't miss anything, there wasn't basically outside of the thread on #t-cargo.
This one is temporary until the
Well not really. The discussion as unfortunately stalled and gone a bit outside: After reading more carefully this message from @joshtriplett, I'm not sure if that means that means that I should have implement my proposed syntax or not instead of those two cmd options ? EDIT: I forgot to mention that the goal of this PR was to have something that peoples could use to enable the checking of well known names and values without needing to wait on a potential future syntax or using
Having a command line option for enabling custom
Yeah, sure (will try to open it this week). |
Just FYI, I've created an tracking issue for the whole |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it's good to move forwards. We can focus on how to deal with custom/external cfg later. Thanks!
BTW, have you found any mean to solve the Windows normalization problem 🤔
@bors r+ |
📌 Commit 02cd944 has been approved by |
fn features_args(cx: &Context<'_, '_>, unit: &Unit) -> Vec<OsString> { | ||
let mut args = Vec::with_capacity(unit.features.len() + 2); | ||
/// All active features for the unit passed as --cfg | ||
fn features_args(_cx: &Context<'_, '_>, unit: &Unit) -> Vec<OsString> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this unused parameter left behind?
I have a few concerns about this PR:
|
☀️ Test successful - checks-actions |
Yes I can make my priority but I'm not sure how to solve it and yes the problem is around quoting; I think that on unix it's
I would prefer to NOT to that because we wouldn't be able to test the absence of the lint firing, their could be extra features, or simply input where their shouldn't be. I would really prefer to check the process args because they are less error prone and mostly because they work as an anti-regression test (like extra values, ...).
They don't have the same effect at all. I could conceivably taught of situations where one could only want features + names or features + values. I think the distinction between them if pretty important, at least until cargo as a way to have custom check cfg. I will prepare a PR to merge them in
Yes I can do that. May I ask why ? (It doesn't seems to be done for other features, just wondering) |
That can be checked with Checking the process arguments will likely be difficult. Generally for our end-to-end tests, it is helpful to validate that the entire chain is working as expected, rather than just a middle piece. I understand checking for specific arguments can be more precise, I have needed it several times for features, but there isn't really a good solution for that right now.
Overall I'm concerned about the complexity of this feature. It seems to be growing beyond what the RFC initially presented. I would expect
It helps organize tests in a few ways:
There's a long list of modules here where most of them are specific features. |
Update cargo 11 commits in e2e2dddebe66dfc1403a312653557e332445308b..dba5baf4345858c591517b24801902a062c399f8 2022-04-05 17:04:53 +0000 to 2022-04-13 21:58:27 +0000 - Part 6 of RFC2906 - Switch the inheritance source from `workspace` to… (rust-lang/cargo#10564) - Part 5 of RFC2906 - Add support for inheriting `rust-version` (rust-lang/cargo#10563) - Add support for rustc --check-cfg well known names and values (rust-lang/cargo#10486) - Reserve filename `Cargo.toml.orig` in `cargo package` (rust-lang/cargo#10551) - Retry command invocation with argfile (rust-lang/cargo#10546) - Add a progress indicator for `cargo clean` (rust-lang/cargo#10236) - Ensure host units don't depend on Docscrape units, fixes rust-lang/cargo#10545 (rust-lang/cargo#10549) - Fix docs: Bindeps env vars are passed to build script at runtime (rust-lang/cargo#10550) - Part 4 of RFC2906 - Add support for inheriting `readme` (rust-lang/cargo#10548) - Part 3 of RFC2906 - Add support for inheriting `license-path`, and `depednency.path` (rust-lang/cargo#10538) - Bump to 0.63.0, update changelog (rust-lang/cargo#10544)
Update cargo 11 commits in e2e2dddebe66dfc1403a312653557e332445308b..dba5baf4345858c591517b24801902a062c399f8 2022-04-05 17:04:53 +0000 to 2022-04-13 21:58:27 +0000 - Part 6 of RFC2906 - Switch the inheritance source from `workspace` to… (rust-lang/cargo#10564) - Part 5 of RFC2906 - Add support for inheriting `rust-version` (rust-lang/cargo#10563) - Add support for rustc --check-cfg well known names and values (rust-lang/cargo#10486) - Reserve filename `Cargo.toml.orig` in `cargo package` (rust-lang/cargo#10551) - Retry command invocation with argfile (rust-lang/cargo#10546) - Add a progress indicator for `cargo clean` (rust-lang/cargo#10236) - Ensure host units don't depend on Docscrape units, fixes rust-lang/cargo#10545 (rust-lang/cargo#10549) - Fix docs: Bindeps env vars are passed to build script at runtime (rust-lang/cargo#10550) - Part 4 of RFC2906 - Add support for inheriting `readme` (rust-lang/cargo#10548) - Part 3 of RFC2906 - Add support for inheriting `license-path`, and `depednency.path` (rust-lang/cargo#10538) - Bump to 0.63.0, update changelog (rust-lang/cargo#10544)
I've opened #10566 to fix all your concerns.
The lint is only fired if a name or a value is not expected, having an extra item in the list of expected values would not trigger the lint as I would need to check it which is impossible as I would need to check everything which would be impossible.
I completely agree with you there are too many options but those exist because
Overall I think having those options is good (at least for initial experimentation) and I think that cargo could stabilize and enable by default: features, names (with at least |
Improve support of condition compilation checking This PR is a series of improvements to the check-cfg implementation. ### What does this PR try to resolve? This PR resolve the concern expressed in #10486 (comment) that is: * Fixing the tests on Windows: e8aa51d * Merging all the -Z flags under -Zcheck-cfg: 969e282 * Moving of all of the check-cfg tests into a separate module: c18b442 * And removing of an unused parameter: 068bdf4 ### How should we test and review this PR? This PR should be reviewed commit by commit and tested with the automated tests or examples. ### Additional information I decided to use a custom macro to make the test functional under Windows, the macro generate a contains line with the correct escaping depending on the platform (windows or not windows).
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 valuesHow should we test and review this PR?
Testing
cargo check -Z check-cfg-well-known-names
andcargo check -Z check-cfg-well-known-values
Review
This PR contains one commit that split
features_args
intocheck_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
: #10408cargo doc
support: #10428