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

Use [lints.rust.unexpected_cfgs.check-cfg] instead of hacky check-cfg workaround #6583

Open
Urgau opened this issue May 24, 2024 · 2 comments
Labels
A-ci Area: The continuous integration setup

Comments

@Urgau
Copy link

Urgau commented May 24, 2024

With the release of rust-lang/cargo#13913 (in nightly-2024-05-19), there is no longer any need for the kind of workarounds employed in #6538. Cargo has gain the ability to declare --check-cfg args directly inside the [lints] table with [lints.rust.unexpected_cfgs.check-cfg]1:

Cargo.toml:

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

Note that the diagnostic output of the lint has been updated to suggest the [lints] approach first. You can use it to guide you through the --check-cfg arguments that may need to be added.

Originally posted by @Urgau in #6538 (comment)

Footnotes

  1. take effect on Rust 1.80 (current nightly), is ignored on Rust 1.79 (current beta), and produce an unused warning below

@mox692 mox692 added the A-ci Area: The continuous integration setup label May 24, 2024
@Urgau Urgau changed the title Using [lints.rust.unexpected_cfgs.check-cfg] instead of hacky workaround Use [lints.rust.unexpected_cfgs.check-cfg] instead of hacky check-cfg workaround May 24, 2024
@Darksonn
Copy link
Contributor

Will this work on our MSRV of Rust 1.63?

@Urgau
Copy link
Author

Urgau commented May 24, 2024

There is no reason it wouldn't. The feature is only active with Rust 1.80.
And while [lints.rust.unexpected_cfgs.check-cfg] produces a unused warning for Rust 1.78 and below, it is only present in local development, thanks to a --cap-lints-like system in Cargo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ci Area: The continuous integration setup
Projects
None yet
Development

No branches or pull requests

3 participants