dtolnay / cxx

Safe interop between Rust and C++
https://cxx.rs
Apache License 2.0
5.68k stars 320 forks source link

Resolve unexpected_cfgs warning #1344

Closed dtolnay closed 1 month ago

dtolnay commented 1 month ago

Context: https://blog.rust-lang.org/2024/05/06/check-cfg.html

Urgau commented 1 month ago

Heads up, with the release of rust-lang/cargo#13913 (in nightly-2024-05-19), there is no longer any need to allow the lint to avoid a build.rs as done in this PR. Cargo has now 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(trybuild)'] }

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.

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