-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Remove implicit names and values from --cfg
in --check-cfg
#99519
Conversation
r? @JohnTitor (rust-highfive has picked a reviewer for you, use r? to override) |
I'm not a fan of this, even though it would have found the bug of #98147 way earlier. I think it's not worth the cost paid in longer command invocations. Also, when you type |
This is more of a t-compiler PR than docs one, so r? @petrochenkov |
I don't think the cost of having longer CLI args is problematic because:
If it's just cmd args nothing, BUT setting the condition means using the cfg in the code, so having |
In the current implementation, if you have
It's fine that it's technically supported, but I believe that reducing noise in command line arguments should be a goal. Sometimes you do want to run with |
Not if it's coupled with My main problem with the implicitness is that it's implicit and leads to unexpected problems that we even saw in the
I don't know if it should be goal but I certainly don't think |
I think we can try using these stricter rules while the feature is unstable, and even after that. It will be a backward compatible change to not require I'm going to mark this as waiting on team to gather feedback. |
Going both ways is backwards compatible as per Rust's semver rules, because it's a lint. But yes, breakage is lower one way than going the other way. |
Visiting after T-compiler meeting (see Zulip notes). The opinion is to tentatively move forward with @rustbot label -I-compiler-nominated |
Based on the previous comment, this is no longer waiting on team, back on the review queue. @rustbot label -S-waiting-on-team +S-waiting-on-review |
Okay, the implementation is trivial so @bors r+ |
…askrgr Rollup of 7 pull requests Successful merges: - rust-lang#99519 (Remove implicit names and values from `--cfg` in `--check-cfg`) - rust-lang#99620 (`-Z location-detail`: provide option to disable all location details) - rust-lang#99932 (Fix unwinding on certain platforms when debug assertions are enabled) - rust-lang#99973 (Layout things) - rust-lang#99980 (Remove more Clean trait implementations) - rust-lang#99984 (Fix compat.rs for `cfg(miri)`) - rust-lang#99986 (Add wrap suggestions for record variants) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
…henkov Add warning against unexpected --cfg with --check-cfg This PR adds a warning when an unexpected `--cfg` is specified but not in the specified list of `--check-cfg`. This is the follow-up PR I mentioned in rust-lang#99519. r? `@petrochenkov`
…henkov Add warning against unexpected --cfg with --check-cfg This PR adds a warning when an unexpected `--cfg` is specified but not in the specified list of `--check-cfg`. This is the follow-up PR I mentioned in rust-lang#99519. r? `@petrochenkov`
…henkov Add warning against unexpected --cfg with --check-cfg This PR adds a warning when an unexpected `--cfg` is specified but not in the specified list of `--check-cfg`. This is the follow-up PR I mentioned in rust-lang#99519. r? ``@petrochenkov``
…henkov Add warning against unexpected --cfg with --check-cfg This PR adds a warning when an unexpected `--cfg` is specified but not in the specified list of `--check-cfg`. This is the follow-up PR I mentioned in rust-lang#99519. r? ```@petrochenkov```
…henkov Add warning against unexpected --cfg with --check-cfg This PR adds a warning when an unexpected `--cfg` is specified but not in the specified list of `--check-cfg`. This is the follow-up PR I mentioned in rust-lang#99519. r? ````@petrochenkov````
…henkov Add warning against unexpected --cfg with --check-cfg This PR adds a warning when an unexpected `--cfg` is specified but not in the specified list of `--check-cfg`. This is the follow-up PR I mentioned in rust-lang#99519. r? `````@petrochenkov`````
…henkov Add warning against unexpected --cfg with --check-cfg This PR adds a warning when an unexpected `--cfg` is specified but not in the specified list of `--check-cfg`. This is the follow-up PR I mentioned in rust-lang#99519. r? `@petrochenkov`
…nkov Add warning against unexpected --cfg with --check-cfg This PR adds a warning when an unexpected `--cfg` is specified but not in the specified list of `--check-cfg`. This is the follow-up PR I mentioned in rust-lang#99519. r? `@petrochenkov`
…trochenkov Remove `--check-cfg` checking of command line `--cfg` args Back in rust-lang#100574 we added to the `unexpected_cfgs` lint the checking of `--cfg` CLI arguments and emitted unexpected names and values for them. The implementation works as expected, but it's usability in particular when using it in combination with Cargo+`RUSTFLAGS` as people who set `RUSTFLAGS=--cfg=tokio_unstable` (or whatever) have `unexpected_cfgs` warnings on all of their crates is debatable. ~~To fix this issue this PR proposes that we split the CLI argument checking into it's own separate allow-by-default lint: `unexpected_cli_cfgs`.~~ ~~This has the advantage of letting people who want CLI warnings have them (although not by default anymore), while still linting on every unexpected cfg name and values in the code.~~ After some discussion with the Cargo team ([Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/check-cfg.20and.20RUSTFLAGS.20interaction)) and member of the compiler team (see below), I propose that we follow the suggestion from `@epage:` never check `--cfg` arguments, but still reserve us the possibility to do it later. We would still lint on unexpected cfgs found in the source code no matter the `--cfg` args passed. This mean reverting rust-lang#100574 but NOT rust-lang#99519. r? `@petrochenkov`
Rollup merge of rust-lang#117522 - Urgau:check-cfg-cli-own-lint, r=petrochenkov Remove `--check-cfg` checking of command line `--cfg` args Back in rust-lang#100574 we added to the `unexpected_cfgs` lint the checking of `--cfg` CLI arguments and emitted unexpected names and values for them. The implementation works as expected, but it's usability in particular when using it in combination with Cargo+`RUSTFLAGS` as people who set `RUSTFLAGS=--cfg=tokio_unstable` (or whatever) have `unexpected_cfgs` warnings on all of their crates is debatable. ~~To fix this issue this PR proposes that we split the CLI argument checking into it's own separate allow-by-default lint: `unexpected_cli_cfgs`.~~ ~~This has the advantage of letting people who want CLI warnings have them (although not by default anymore), while still linting on every unexpected cfg name and values in the code.~~ After some discussion with the Cargo team ([Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/check-cfg.20and.20RUSTFLAGS.20interaction)) and member of the compiler team (see below), I propose that we follow the suggestion from `@epage:` never check `--cfg` arguments, but still reserve us the possibility to do it later. We would still lint on unexpected cfgs found in the source code no matter the `--cfg` args passed. This mean reverting rust-lang#100574 but NOT rust-lang#99519. r? `@petrochenkov`
Remove `--check-cfg` checking of command line `--cfg` args Back in rust-lang/rust#100574 we added to the `unexpected_cfgs` lint the checking of `--cfg` CLI arguments and emitted unexpected names and values for them. The implementation works as expected, but it's usability in particular when using it in combination with Cargo+`RUSTFLAGS` as people who set `RUSTFLAGS=--cfg=tokio_unstable` (or whatever) have `unexpected_cfgs` warnings on all of their crates is debatable. ~~To fix this issue this PR proposes that we split the CLI argument checking into it's own separate allow-by-default lint: `unexpected_cli_cfgs`.~~ ~~This has the advantage of letting people who want CLI warnings have them (although not by default anymore), while still linting on every unexpected cfg name and values in the code.~~ After some discussion with the Cargo team ([Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/check-cfg.20and.20RUSTFLAGS.20interaction)) and member of the compiler team (see below), I propose that we follow the suggestion from `@epage:` never check `--cfg` arguments, but still reserve us the possibility to do it later. We would still lint on unexpected cfgs found in the source code no matter the `--cfg` args passed. This mean reverting rust-lang/rust#100574 but NOT rust-lang/rust#99519. r? `@petrochenkov`
This PR remove the implicit names and values from
--cfg
in--check-cfg
because the behavior is quite surprising but also because it's really easy to inadvertently really on the implicitness and when the--cfg
is not set anymore to have an unexpected warning from an unexpected condition that pass with the implicitness.This change in behavior will also enable us to warn when an unexpected
--cfg
is passed, ex: the user wrote--cfg=unstabl
instead of--cfg=unstable
. The implementation of the warning will be done in a follow-up PR.cc @petrochenkov