Skip to content

Commit

Permalink
Move the check-cfg lint stuff from the build scritp to Cargo.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
tatsuya6502 committed Sep 14, 2024
1 parent a70218a commit bd5e447
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 24 deletions.
11 changes: 11 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
25 changes: 1 addition & 24 deletions build.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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() {}

0 comments on commit bd5e447

Please sign in to comment.