-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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 special check-cfg
lint config for the unexpected_cfgs
lint
#13913
Merged
+386
−37
Conversation
This file contains 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
rustbot
added
A-build-execution
Area: anything dealing with executing the compiler
A-documenting-cargo-itself
Area: Cargo's documentation
A-manifest
Area: Cargo.toml issues
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
labels
May 14, 2024
Urgau
force-pushed
the
check-cfg-lints-sub-config
branch
2 times, most recently
from
May 14, 2024 20:27
021ba1f
to
628542e
Compare
epage
reviewed
May 14, 2024
epage
reviewed
May 14, 2024
epage
reviewed
May 14, 2024
epage
reviewed
May 14, 2024
epage
reviewed
May 14, 2024
epage
reviewed
May 14, 2024
epage
reviewed
May 14, 2024
epage
changed the title
Add special
Add special May 14, 2024
check-cfg
sub-config for the unexpected_cfgs
lintcheck-cfg
lint config for the unexpected_cfgs
lint
Urgau
force-pushed
the
check-cfg-lints-sub-config
branch
from
May 15, 2024 19:34
628542e
to
d3cfef0
Compare
Urgau
force-pushed
the
check-cfg-lints-sub-config
branch
2 times, most recently
from
May 15, 2024 21:34
4dfede9
to
0b5be58
Compare
This comment was marked as resolved.
This comment was marked as resolved.
bors
added a commit
that referenced
this pull request
May 15, 2024
Add special `check-cfg` lint config for the `unexpected_cfgs` lint This PR adds a special `check-cfg` lint config for the `unexpected_cfgs` lint, as it was decided by T-cargo (in today's meeting). The goal of this lint config is to provide a simple and cost-less alternative to the build-script `cargo::rustc-check-cfg` instruction. ```toml [lints.rust] unexpected_cfgs = { check-cfg = ["cfg(foo, values(\"bar\"))"] } ``` Regarding the implementation, everything is as straight forward as possible, nothing over-engineered; I added the possibility to omit the `level` field if a sub-config is specified instead, since it seems useful and was easy to implement. There are many small-ish commit, I recommend reviewing them independently. r? `@epage` (or `@weihanglo` maybe)
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
bors
added
S-waiting-on-author
Status: The marked PR is awaiting some action (such as code changes) from the PR author.
and removed
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
labels
May 15, 2024
This comment was marked as resolved.
This comment was marked as resolved.
RalfJung
pushed a commit
to RalfJung/miri
that referenced
this pull request
May 22, 2024
Update `unexpected_cfgs` lint for Cargo new `check-cfg` config This PR updates the diagnostics output of the `unexpected_cfgs` lint for Cargo new `check-cfg` config. It's a simple and cost-less alternative to the build-script `cargo::rustc-check-cfg` instruction. ```toml [lints.rust] unexpected_cfgs = { level = "warn", check-cfg = ['cfg(foo, values("bar"))'] } ``` This PR also adds a Cargo specific section regarding check-cfg and Cargo inside rustc's book (motivation is described inside the file, but mainly check-cfg is a rustc feature not a Cargo one, Cargo only enabled the feature, it does not own it; T-cargo even considers the `check-cfg` lint config to be an implementation detail). This PR also updates the links to refer to that sub-page when using Cargo from rustc. As well as updating the lint doc to refer to the check-cfg docs. ~**Not to be merged before rust-lang/cargo#13913 reaches master!**~ (EDIT: merged in rust-lang/rust#125237) `@rustbot` label +F-check-cfg r? `@fmease` *(feel free to roll)* Fixes rust-lang/rust#124800 cc `@epage` `@weihanglo`
bors
added a commit
that referenced
this pull request
May 22, 2024
[beta-1.79] fix(toml): Don't warn on lints.rust.unexpected_cfgs.check-cfg Beta backports: - #13913 (sort of): removes just the lint warning (in a different way to be minimal) so we reduce warning noise for people using this key on nightly In order to make CI pass, the following PRs are also cherry-picked: - #13865 - #13834 (only `time` due to rust-lang/rust#125319) - #13901 - #13931 - #13920 - #13890 - disable link check (not a cherry pick)
This was referenced May 23, 2024
Use
[lints.rust.unexpected_cfgs.check-cfg]
instead of hacky check-cfg workaround
tokio-rs/tokio#6583
Open
This was referenced May 24, 2024
Urgau
referenced
this pull request
in ch32-rs/ch32-hal
May 24, 2024
This was referenced May 24, 2024
Merged
flip1995
pushed a commit
to flip1995/rust-clippy
that referenced
this pull request
May 24, 2024
Update `unexpected_cfgs` lint for Cargo new `check-cfg` config This PR updates the diagnostics output of the `unexpected_cfgs` lint for Cargo new `check-cfg` config. It's a simple and cost-less alternative to the build-script `cargo::rustc-check-cfg` instruction. ```toml [lints.rust] unexpected_cfgs = { level = "warn", check-cfg = ['cfg(foo, values("bar"))'] } ``` This PR also adds a Cargo specific section regarding check-cfg and Cargo inside rustc's book (motivation is described inside the file, but mainly check-cfg is a rustc feature not a Cargo one, Cargo only enabled the feature, it does not own it; T-cargo even considers the `check-cfg` lint config to be an implementation detail). This PR also updates the links to refer to that sub-page when using Cargo from rustc. As well as updating the lint doc to refer to the check-cfg docs. ~**Not to be merged before rust-lang/cargo#13913 reaches master!**~ (EDIT: merged in rust-lang/rust#125237) `@rustbot` label +F-check-cfg r? `@fmease` *(feel free to roll)* Fixes rust-lang/rust#124800 cc `@epage` `@weihanglo`
rfcbot
added
finished-final-comment-period
FCP complete
to-announce
and removed
final-comment-period
FCP — a period for last comments before action is taken
labels
May 27, 2024
This was referenced May 27, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-build-execution
Area: anything dealing with executing the compiler
A-documenting-cargo-itself
Area: Cargo's documentation
A-manifest
Area: Cargo.toml issues
disposition-merge
FCP with intent to merge
finished-final-comment-period
FCP complete
S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
T-cargo
Team: Cargo
to-announce
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.
What does this PR try to resolve?
This PR adds a special
check-cfg
lint config for theunexpected_cfgs
lint, as it was decided by T-cargo (in today's meeting).The goal of this lint config is to provide a simple and cost-less alternative to the build-script
cargo::rustc-check-cfg
instruction.How should we test and review this PR?
I recommand reviewing commit by commit; and looking at all the new tests added in
check_cfg.rs
, I tried making them as exhaustive as I could, many of them are very similar to their non-config counterpart.Additional information
I didn't add (actually removed from the 1st version of this PR) the possibility to omit the
level
field ifcheck-cfg
is specified, #13913 (comment).Regarding the implementation, I tried making it is as straight forward as possible, nothing over-engineered or complex.
r? @epage (or @weihanglo maybe)