From bd5e447bc228de4e43c3573e9c741b5b47d01a70 Mon Sep 17 00:00:00 2001 From: Tatsuya Kawano Date: Sat, 14 Sep 2024 16:28:18 +0000 Subject: [PATCH] Move the `check-cfg` lint stuff from the build scritp to `Cargo.toml` --- Cargo.toml | 11 +++++++++++ build.rs | 25 +------------------------ 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0fb928b5..b363bc2a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -87,6 +87,17 @@ trybuild = "1.0" [target.'cfg(rustver)'.build-dependencies] rustc_version = "0.4.0" +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = [ + "cfg(armv5te)", + "cfg(beta_clippy)", + "cfg(kani)", + "cfg(mips)", + "cfg(rustver)", + "cfg(skip_large_mem_tests)", + "cfg(trybuild)", +] } + # https://docs.rs/about/metadata [package.metadata.docs.rs] # Build the doc at docs.rs with some features enabled. diff --git a/build.rs b/build.rs index b82d02a6..72a59c0e 100644 --- a/build.rs +++ b/build.rs @@ -1,15 +1,3 @@ -#![allow(unexpected_cfgs)] // for `#[cfg(rustver)]` in this build.rs. - -const ALLOWED_CFG_NAMES: &[&str] = &[ - "armv5te", - "beta_clippy", - "kani", - "mips", - "rustver", - "skip_large_mem_tests", - "trybuild", -]; - #[cfg(rustver)] fn main() { use rustc_version::version; @@ -18,18 +6,7 @@ fn main() { "cargo:rustc-env=RUSTC_SEMVER={}.{}", version.major, version.minor ); - - allow_cfgs(ALLOWED_CFG_NAMES); } #[cfg(not(rustver))] -fn main() { - allow_cfgs(ALLOWED_CFG_NAMES); -} - -/// Tells `rustc` to allow `#[cfg(...)]` with the given names. -fn allow_cfgs(names: &[&str]) { - for name in names.iter() { - println!("cargo:rustc-check-cfg=cfg({name})"); - } -} +fn main() {}