Add way to express that no values are expected with check-cfg#119930
Merged
bors merged 1 commit intorust-lang:masterfrom Jan 17, 2024
Merged
Add way to express that no values are expected with check-cfg#119930bors merged 1 commit intorust-lang:masterfrom
bors merged 1 commit intorust-lang:masterfrom
Conversation
This comment has been minimized.
This comment has been minimized.
35f649e to
41b69aa
Compare
Contributor
|
@bors r+ |
Collaborator
Collaborator
Collaborator
|
☀️ Test successful - checks-actions |
Collaborator
|
Finished benchmarking commit (c58a5da): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 665.924s -> 664.091s (-0.28%) |
Urgau
added a commit
to Urgau/cargo
that referenced
this pull request
Jan 18, 2024
Urgau
added a commit
to Urgau/cargo
that referenced
this pull request
Jan 18, 2024
bors
added a commit
to rust-lang/cargo
that referenced
this pull request
Jan 18, 2024
Go back to passing an empty `values()` when no features are declared This PR is basically a revert of #13011, which made the `--check-cfg` invocation be `cfg()` when no features are declared instead of `cfg(feature, values())` since it meant declaring that the config `feature` were to be available in this form: `#[cfg(feature)]`, which is not the case. Thankfully after some brainstorming, I [proposed](rust-lang/rust#119930) changing the behavior of empty `values()` in `rustc` to no longer imply the _none_ value and simply create an empty set of expected values. 😃 For Cargo, always using `cfg(feature, values(...))` means that the config `feature` is always expected, regardless of the number of features. This makes the warning better, as it will now always be `unexpected config value` (instead of `unexpected config name`). 🎉 Fixes #13011 (comment) as well as the concern in the [tracking issue](#10554). r? `@epage`
This was referenced Jan 18, 2024
stupendoussuperpowers
pushed a commit
to stupendoussuperpowers/cargo
that referenced
this pull request
Feb 28, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds way to express no-values (no values expected) with
--check-cfgby making emptyvalues()no longer meanvalues(none())(internal:&[None]) and now be an empty list (internal:&[]).Context
Currently
--check-cfghas a way to express that any value is expected withvalues(any()), but has no way to do the inverse and say that no value is expected.This would be particularly useful for build systems that control a config name and it's values as they could always declare a config name as expected and if in the current state they have values pass them and if not pass an empty list.
To give a more concrete example, Cargo
--check-cfgcurrently needs to generate:--check-cfg=cfg(feature, values(...))for the case with declared features--check-cfg=cfg()for the case without any features declaredThis means that when there are no features declared, users will get an
unexpected config namebut from the point of view of Cargo the config namefeatureis expected, it's just that for now there aren't any values for it.See Cargo
check_cfg_argsfunction for more details.De-specializing empty
values()To solve this issue I propose that we "de-specialize" empty
values()to no longer meanvalues(none())but to actually mean empty set/list. This is one of the last source of confusion for my-self and others with the--check-cfgsyntax.Before the new
cfg()syntax, defining the none variant was only possible under certain circumstances, so in #111068 I decided to makevalues()to mean the none variant, but it is no longer necessary since #119473 which introduced thenone()syntax.A simplified representation of the proposed "de-specialization" would be:
cfg(name)/cfg(name, values(none()))&[None]cfg(name, values())&[]Note that I have my-self made the mistake of using an empty
values()as meaning empty set, see rust-lang/cargo#13011.@rustbot label +F-check-cfg
r? @petrochenkov
cc @epage