Skip to content

[build.rs] Support unexpected_cfgs lint #1204

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

Merged
merged 1 commit into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,20 @@ fn main() {
let version_cfgs = parse_version_cfgs_from_cargo_toml();
let rustc_version = rustc_version();

if rustc_version >= (Version { major: 1, minor: 77, patch: 0 }) {
// This tells the `unexpected_cfgs` lint to expect to see all of these
// `cfg`s. The `cargo::` syntax was only added in 1.77, so we don't emit
// these on earlier toolchain versions.
for version_cfg in &version_cfgs {
println!("cargo:rustc-check-cfg=cfg({})", version_cfg.cfg_name);
}
// TODO(https://github.com/rust-lang/rust/issues/124816): Remove these
// once they're no longer needed.
println!("cargo:rustc-check-cfg=cfg(doc_cfg)");
println!("cargo:rustc-check-cfg=cfg(kani)");
println!("cargo:rustc-check-cfg=cfg(__INTERNAL_USE_ONLY_NIGHTLY_FEATURES_IN_TESTS)");
}

for version_cfg in version_cfgs {
if rustc_version >= version_cfg.version {
println!("cargo:rustc-cfg={}", version_cfg.cfg_name);
Expand Down
6 changes: 2 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,7 @@
// `unknown_lints` is `warn` by default and we deny warnings in CI, so without
// this attribute, any unknown lint would cause a CI failure when testing with
// our MSRV.
//
// TODO(#1201): Remove `unexpected_cfgs`
#![allow(unknown_lints, unexpected_cfgs)]
#![allow(unknown_lints)]
#![deny(renamed_and_removed_lints)]
#![deny(
anonymous_parameters,
Expand Down Expand Up @@ -8926,7 +8924,7 @@ mod tests {
vector_signed_long,
vector_unsigned_long
);
#[cfg(all(target_arch = "aarch64", zerocopy_aarch_simd))]
#[cfg(all(target_arch = "aarch64", zerocopy_aarch64_simd))]
#[rustfmt::skip]
test_simd_arch_mod!(
aarch64, float32x2_t, float32x4_t, float64x1_t, float64x2_t, int8x8_t, int8x8x2_t,
Expand Down
Loading