-
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
Add new simpler and more explicit syntax for check-cfg #111072
Conversation
This comment has been minimized.
This comment has been minimized.
a01a326
to
3b54cec
Compare
This comment has been minimized.
This comment has been minimized.
3b54cec
to
e072419
Compare
Blocked on #111068. |
This comment was marked as resolved.
This comment was marked as resolved.
e072419
to
6846f33
Compare
How can |
Does UPD: Looks like |
With this new design we cannot specify a name as known, while keeping its list of values unknown, right? Previously |
Remember that we can only lint on values for which we have an entry for, if we don't have one then it's not a value problem but a name problem and this is gated under
Not exactly, for
Enable checking of the builtin values without triggering on potentially unexpected cfg. |
Yes, this is the only "regression" of the new design, but I've yet to found a example where this would be useful. The only place where it is useful is in the compiler for If a consumer of
Btw, no need for @rustbot ready |
So what we really need to cover all cases without regressions (without any syntax beautifications) is:
|
In that case we probably need some short syntax for the commonly used combination |
Agree for these two.
As I said, I don't think this is useful for users, as users knows all the possible values. Otherwise they couldn't possible use cfgs in any meaningful way.
👍 (but note that there isn't currently any plan to enable this by default in cargo)
If cargo were to enable all things, it would be with my syntax |
@bors r+ |
@Urgau is the syntax in the OP still up to date? (I don't immediately get what the syntax means, specifically the |
Yes, the PR description, the commit message and the MCP are all up to date. For more information, I would highly suggest reading the
It's a pre-existing unstable feature, so yes it's gated. |
…iaskrgr Rollup of 5 pull requests Successful merges: - rust-lang#111072 (Add new simpler and more explicit syntax for check-cfg) - rust-lang#116717 (Special case iterator chain checks for suggestion) - rust-lang#116719 (Add MonoItems and Instance to stable_mir) - rust-lang#116787 (Implement an internal lint encouraging use of `Span::eq_ctxt`) - rust-lang#116827 (Make `handle_options` public again.) r? `@ghost` `@rustbot` modify labels: rollup
(Sorry for commenting on details after MCP was accepted and PR approved...) For me it looks weird that Also the documentation seems to have a Anyway, thanks for answering my questions. |
Rollup merge of rust-lang#111072 - Urgau:check-cfg-new-syntax, r=petrochenkov Add new simpler and more explicit syntax for check-cfg <details> <summary> Old proposition (before the MCP) </summary> This PR adds a new simpler and more explicit syntax for check-cfg. It consist of two new form: - `exhaustive(names, values)` - `configure(name, "value1", "value2", ... "valueN")` The preview forms `names(...)` and `values(...)` have implicit meaning that are not strait-forward. In particular `values(foo)`&`values(bar)` and `names(foo, bar)` are not equivalent which has created [some confusions](rust-lang#98080). Also the `names()` and `values()` form are not clear either and again created some confusions where peoples believed that `values()`&`values(foo)` could be reduced to just `values(foo)`. To fix that the two new forms are made to be explicit and simpler. See the table of correspondence: - `names()` -> `exhaustive(names)` - `values()` -> `exhaustive(values)` - `names(foo)` -> `exhaustive(names)`&`configure(foo)` - `values(foo)` -> `configure(foo)` - `values(feat, "foo", "bar")` -> `configure(feat, "foo", "bar")` - `values(foo)`&`values(bar)` -> `configure(foo, bar)` - `names()`&`values()`&`values(my_cfg)` -> `exhaustive(names, values)`&`configure(my_cfg)` Another benefits of the new syntax is that it allow for further options (like conditional checking for --cfg, currently always on) without syntax change. The two previous forms are deprecated and will be removed once cargo and beta rustc have the necessary support. </details> This PR is the first part of the implementation of [MCP636 - Simplify and improve explicitness of the check-cfg syntax](rust-lang/compiler-team#636). ## New `cfg` form It introduces the new [`cfg` form](rust-lang/compiler-team#636) and deprecate the other two: ``` rustc --check-cfg 'cfg(name1, ..., nameN, values("value1", "value2", ... "valueN"))' ``` ## Default built-in names and values It also changes the default for the built-in names and values checking. - Built-in values checking would always be activated as long as a `--check-cfg` argument is present - Built-in names checking would always be activated as long as a `--check-cfg` argument is present **unless** if any `cfg(any())` arg is passed ~~**Note: depends on rust-lang#111068 but is reviewable (last two commits)!**~~ Resolve rust-lang/compiler-team#636 r? `@petrochenkov`
57: Pull upstream master 2023 10 18 r=pietroalbini a=Veykril * rust-lang/rust#116505 * rust-lang/rust#116840 * rust-lang/rust#116767 * rust-lang/rust#116855 * rust-lang/rust#116827 * rust-lang/rust#116787 * rust-lang/rust#116719 * rust-lang/rust#116717 * rust-lang/rust#111072 * rust-lang/rust#116844 * rust-lang/rust#115577 * rust-lang/rust#116756 * rust-lang/rust#116518 Co-authored-by: Urgau <urgau@numericable.fr> Co-authored-by: Esteban Küber <esteban@kuber.com.ar> Co-authored-by: Deadbeef <ent3rm4n@gmail.com> Co-authored-by: Ralf Jung <post@ralfj.de> Co-authored-by: Camille GILLOT <gillot.camille@gmail.com> Co-authored-by: Celina G. Val <celinval@amazon.com> Co-authored-by: Nicholas Nethercote <n.nethercote@gmail.com> Co-authored-by: Arthur Lafrance <lafrancearthur@gmail.com> Co-authored-by: Nikolay Arhipov <n@arhipov.net> Co-authored-by: Nikita Popov <npopov@redhat.com> Co-authored-by: bors <bors@rust-lang.org>
btw, if you wish to continue discussing it let's do that on Zulip
Yes, missed-it. |
Adjust `-Zcheck-cfg` for new rustc syntax and behavior rust-lang/rust#111072 introduced a new syntax for `rustc` `--check-cfg` argument. This PR adjust cargo `-Zcheck-cfg` for new that new syntax and behavior. This PR removes all the `-Zcheck-cfg` options (`features`, `names`, `values`, `output`), as they don't make much sense now since with the new `rustc` behavior: `features`, `names` and `values` are all combine together and the `output` option was only here because the other were. Now the new behavior from cargo is to always pass one `--check-cfg` argument to rustc for the `feature`s which implicitly enables well known names and values.
…k-cfg, r=<try> Prepare the `bootstrap` tool for the new check-cfg syntax This PR prepare the `bootstrap` tool for the [new check-cfg syntax](rust-lang#111072) as well as the according [changes to Cargo](rust-lang/cargo#12845). Note that while the new syntax can technically available on stage > 2, we actually cannot use it since we need a cargo version that supports the new syntax which won't happen until the next beta bump (if I understand everything correctly). r? bootstrap
…k-cfg, r=Kobzol Prepare the `bootstrap` tool for the new check-cfg syntax This PR prepare the `bootstrap` tool for the [new check-cfg syntax](rust-lang#111072) as well as the according [changes to Cargo](rust-lang/cargo#12845). ~~Note that while the new syntax can technically available on stage > 2, we actually cannot use it since we need a cargo version that supports the new syntax which won't happen until the next beta bump (if I understand everything correctly).~~ r? bootstrap
…Kobzol Prepare the `bootstrap` tool for the new check-cfg syntax This PR prepare the `bootstrap` tool for the [new check-cfg syntax](rust-lang/rust#111072) as well as the according [changes to Cargo](rust-lang/cargo#12845). ~~Note that while the new syntax can technically available on stage > 2, we actually cannot use it since we need a cargo version that supports the new syntax which won't happen until the next beta bump (if I understand everything correctly).~~ r? bootstrap
…syntax, r=b-naber Remove deprecated `--check-cfg` syntax This PR removes the deprecated `--check-cfg` `names(...)` and `values(...)` syntax. Follow up to rust-lang#111072 Part of rust-lang/compiler-team#636 r? compiler
…syntax, r=b-naber Remove deprecated `--check-cfg` syntax This PR removes the deprecated `--check-cfg` `names(...)` and `values(...)` syntax. Follow up to rust-lang#111072 Part of rust-lang/compiler-team#636 r? compiler
Rollup merge of rust-lang#117981 - Urgau:check-cfg-remove-deprecated-syntax, r=b-naber Remove deprecated `--check-cfg` syntax This PR removes the deprecated `--check-cfg` `names(...)` and `values(...)` syntax. Follow up to rust-lang#111072 Part of rust-lang/compiler-team#636 r? compiler
…Kobzol Prepare the `bootstrap` tool for the new check-cfg syntax This PR prepare the `bootstrap` tool for the [new check-cfg syntax](rust-lang/rust#111072) as well as the according [changes to Cargo](rust-lang/cargo#12845). ~~Note that while the new syntax can technically available on stage > 2, we actually cannot use it since we need a cargo version that supports the new syntax which won't happen until the next beta bump (if I understand everything correctly).~~ r? bootstrap
…Kobzol Prepare the `bootstrap` tool for the new check-cfg syntax This PR prepare the `bootstrap` tool for the [new check-cfg syntax](rust-lang/rust#111072) as well as the according [changes to Cargo](rust-lang/cargo#12845). ~~Note that while the new syntax can technically available on stage > 2, we actually cannot use it since we need a cargo version that supports the new syntax which won't happen until the next beta bump (if I understand everything correctly).~~ r? bootstrap
Old proposition (before the MCP)
This PR adds a new simpler and more explicit syntax for check-cfg. It consist of two new form:
exhaustive(names, values)
configure(name, "value1", "value2", ... "valueN")
The preview forms
names(...)
andvalues(...)
have implicit meaning that are not strait-forward. In particularvalues(foo)
&values(bar)
andnames(foo, bar)
are not equivalent which has created some confusions.Also the
names()
andvalues()
form are not clear either and again created some confusions where peoples believed thatvalues()
&values(foo)
could be reduced to justvalues(foo)
.To fix that the two new forms are made to be explicit and simpler. See the table of correspondence:
names()
->exhaustive(names)
values()
->exhaustive(values)
names(foo)
->exhaustive(names)
&configure(foo)
values(foo)
->configure(foo)
values(feat, "foo", "bar")
->configure(feat, "foo", "bar")
values(foo)
&values(bar)
->configure(foo, bar)
names()
&values()
&values(my_cfg)
->exhaustive(names, values)
&configure(my_cfg)
Another benefits of the new syntax is that it allow for further options (like conditional checking for --cfg, currently always on) without syntax change.
The two previous forms are deprecated and will be removed once cargo and beta rustc have the necessary support.
This PR is the first part of the implementation of MCP636 - Simplify and improve explicitness of the check-cfg syntax.
New
cfg
formIt introduces the new
cfg
form and deprecate the other two:Default built-in names and values
It also changes the default for the built-in names and values checking.
--check-cfg
argument is present--check-cfg
argument is present unless if anycfg(any())
arg is passedNote: depends on #111068 but is reviewable (last two commits)!Resolve rust-lang/compiler-team#636
r? @petrochenkov