Repository navigation
Conversation
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.
View all comments
What does this PR try to resolve?
Since #13571, we now lint by default on unexpected cfgs in Rust code, but one area that is missing are cfg expressions in
Cargo.tomland.cargo/config.toml. This PR address this missing piece by (unstably) introducing-Zcheck-target-cfgsbased onrustc --print=check-cfg.The feature
voluntarily does not always followbut instead follows RustRUSTFLAGS(to avoid mistakes with one-off and for consistency)unexpected_cfgslint configuration:In terms of implementation, one global
--print=check-cfgis retrieved and fetched, packages that have their owncheck-cfginputs have each their own--print=check-cfg, otherwise the expected cfgs will get mixed up. Each--print=check-cfgis cached and only done if necessary.How should we test and review this PR?
As asked I tried putting everything into small commits, they may not reflect the de-coupling possible as they follow the implementation but they are still IMO very useful. However I strongly recommand doing a first-pass of the complete diff first.
In terms of tests, I added some combinations that I though would be useful, I can add more if desired.
Additional information
Documentation for
--print=check-cfg. It was one of motivation of the compiler MCP rust-lang/compiler-team#743.r? @epage