Skip to content
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
merged 5 commits into from
May 17, 2024

Conversation

Urgau
Copy link
Member

@Urgau Urgau commented May 14, 2024

What does this PR try to resolve?

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.

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(foo, values("bar"))'] }

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 if check-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)

@rustbot 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 Urgau force-pushed the check-cfg-lints-sub-config branch 2 times, most recently from 021ba1f to 628542e Compare May 14, 2024 20:27
tests/testsuite/check_cfg.rs Outdated Show resolved Hide resolved
tests/testsuite/check_cfg.rs Outdated Show resolved Hide resolved
@epage epage changed the title Add special check-cfg sub-config for the unexpected_cfgs lint Add special check-cfg lint config for the unexpected_cfgs lint May 14, 2024
@Urgau Urgau force-pushed the check-cfg-lints-sub-config branch from 628542e to d3cfef0 Compare May 15, 2024 19:34
@Urgau Urgau closed this May 15, 2024
@Urgau Urgau deleted the check-cfg-lints-sub-config branch May 15, 2024 19:40
@Urgau Urgau restored the check-cfg-lints-sub-config branch May 15, 2024 19:42
@Urgau Urgau reopened this May 15, 2024
@Urgau Urgau force-pushed the check-cfg-lints-sub-config branch 2 times, most recently from 4dfede9 to 0b5be58 Compare May 15, 2024 21:34
@weihanglo

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)
@bors

This comment was marked as resolved.

@bors

This comment was marked as resolved.

@bors 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
@weihanglo

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)
Urgau referenced this pull request in Lokathor/bytemuck May 24, 2024
Urgau referenced this pull request in ch32-rs/ch32-hal May 24, 2024
Urgau referenced this pull request in esp-rs/esp-idf-sys May 24, 2024
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 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
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants