about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeón Orell Valerian Liehr <me@fmease.dev>2024-05-22 19:04:45 +0200
committerGitHub <noreply@github.com>2024-05-22 19:04:45 +0200
commit8219fd2bc16c80d836e5baaf8c7a8ac758c0b37d (patch)
treeb3baf1694aebf68791f29598db32bf4ae6cf7e21
parent44c7a2dbffef822bd8df3f154b37bf1bc51b1d9c (diff)
parent30e0ab84f985d4da0f9eb802e047f5462f4a8a65 (diff)
downloadrust-8219fd2bc16c80d836e5baaf8c7a8ac758c0b37d.tar.gz
rust-8219fd2bc16c80d836e5baaf8c7a8ac758c0b37d.zip
Rollup merge of #125296 - tesuji:checkcfg-buildstd, r=Nilstrieb,michaelwoerister
Fix `unexpected_cfgs` lint on std

closes #125291

r? rust-lang/compiler
-rw-r--r--library/alloc/Cargo.toml12
-rw-r--r--library/core/Cargo.toml13
-rw-r--r--library/std/Cargo.toml10
-rw-r--r--src/bootstrap/src/lib.rs3
4 files changed, 38 insertions, 0 deletions
diff --git a/library/alloc/Cargo.toml b/library/alloc/Cargo.toml
index 2e7fcb9dbd3..3960f716812 100644
--- a/library/alloc/Cargo.toml
+++ b/library/alloc/Cargo.toml
@@ -40,3 +40,15 @@ compiler-builtins-weak-intrinsics = ["compiler_builtins/weak-intrinsics"]
 panic_immediate_abort = ["core/panic_immediate_abort"]
 # Choose algorithms that are optimized for binary size instead of runtime performance
 optimize_for_size = ["core/optimize_for_size"]
+
+[lints.rust.unexpected_cfgs]
+level = "warn"
+# x.py uses beta cargo, so `check-cfg` entries do not yet take effect
+# for rust-lang/rust. But for users of `-Zbuild-std` it does.
+# The unused warning is waiting for rust-lang/cargo#13925 to reach beta.
+check-cfg = [
+    'cfg(bootstrap)',
+    'cfg(no_global_oom_handling)',
+    'cfg(no_rc)',
+    'cfg(no_sync)',
+]
diff --git a/library/core/Cargo.toml b/library/core/Cargo.toml
index 11d33971f25..daf2612833d 100644
--- a/library/core/Cargo.toml
+++ b/library/core/Cargo.toml
@@ -36,3 +36,16 @@ optimize_for_size = []
 # Make `RefCell` store additional debugging information, which is printed out when
 # a borrow error occurs
 debug_refcell = []
+
+[lints.rust.unexpected_cfgs]
+level = "warn"
+# x.py uses beta cargo, so `check-cfg` entries do not yet take effect
+# for rust-lang/rust. But for users of `-Zbuild-std` it does.
+# The unused warning is waiting for rust-lang/cargo#13925 to reach beta.
+check-cfg = [
+    'cfg(bootstrap)',
+    'cfg(no_fp_fmt_parse)',
+    'cfg(stdarch_intel_sde)',
+    # This matches `EXTRA_CHECK_CFGS` in `src/bootstrap/src/lib.rs`.
+    'cfg(feature, values(any()))',
+]
diff --git a/library/std/Cargo.toml b/library/std/Cargo.toml
index 5b36867fe24..4b8ee4c1309 100644
--- a/library/std/Cargo.toml
+++ b/library/std/Cargo.toml
@@ -97,3 +97,13 @@ heap_size = 0x8000000
 name = "stdbenches"
 path = "benches/lib.rs"
 test = true
+
+[lints.rust.unexpected_cfgs]
+level = "warn"
+check-cfg = [
+    'cfg(bootstrap)',
+    'cfg(backtrace_in_libstd)',
+    'cfg(netbsd10)',
+    'cfg(target_arch, values("xtensa"))',
+    'cfg(feature, values("std", "as_crate"))',
+]
diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs
index 698a576effa..38de5e38000 100644
--- a/src/bootstrap/src/lib.rs
+++ b/src/bootstrap/src/lib.rs
@@ -84,6 +84,9 @@ const EXTRA_CHECK_CFGS: &[(Option<Mode>, &str, Option<&[&'static str]>)] = &[
     (Some(Mode::ToolRustc), "rust_analyzer", None),
     (Some(Mode::ToolStd), "rust_analyzer", None),
     (Some(Mode::Codegen), "parallel_compiler", None),
+    // NOTE: consider updating `check-cfg` entries in `std/Cargo.toml` too.
+    // cfg(bootstrap) remove these once the bootstrap compiler supports
+    // `lints.rust.unexpected_cfgs.check-cfg`
     (Some(Mode::Std), "stdarch_intel_sde", None),
     (Some(Mode::Std), "no_fp_fmt_parse", None),
     (Some(Mode::Std), "no_global_oom_handling", None),