Repository navigation
Correct what makes a configuration option predicate true - #2389
Open
isHeSatoshi wants to merge 1 commit into
Open
isHeSatoshi wants to merge 1 commit into
isHeSatoshi wants to merge 1 commit into
Conversation
The Reference said a configuration option predicate "is true if the option is set, and false if it is unset", which reads as a single set/unset bit per key. That is not how it works: `cfg(foo)` is true only if `foo` is set as a name, and `cfg(foo = "bar")` is true only if `foo` is set with that value. Setting a key to a value does not make the name predicate true, and setting it as a name does not make any key-value predicate true. State the two forms separately and keep the example inline, since the distinction is easy to get wrong and cheap to check.
This branch has not been deployed
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.
Fixes #2004.
The Reference said:
That reads as a single set/unset bit per key, but a name predicate and a key-value predicate for the same key are independent. @epage said in the issue that this needed some further investigation first, so I checked the actual behaviour before writing anything.
Each row below is the
--cfgflags passed torustcon nightly, and the values arecfg!(foo)andcfg!(foo = "bar")in that same program:--cfgcfg!(foo)cfg!(foo = "bar")foofoo="bar"foo="bar"foo="baz"foofoo="bar"Two things follow that are worth being precise about:
cfg.option-key-uniquenessalready says keys do not need to be unique, which is the same idea one level down.So the change states the two forms separately and keeps the example inline, since the distinction is easy to get wrong and cheap to check.
cargo run --package=style-check -- srcpasses. No new links or code blocks are added, so the build and linkcheck jobs are unaffected.