From 63fe640f5d2eb402247906e22b8bf14bf8e90b61 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Sun, 19 May 2024 23:08:59 +0000 Subject: [PATCH 1/6] Update check-cfg lists for core --- library/core/Cargo.toml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/library/core/Cargo.toml b/library/core/Cargo.toml index 11d33971f2563..0c86f430f3250 100644 --- a/library/core/Cargo.toml +++ b/library/core/Cargo.toml @@ -36,3 +36,12 @@ 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" +check-cfg = [ + 'cfg(no_fp_fmt_parse)', + 'cfg(bootstrap)', + 'cfg(stdarch_intel_sde)', + 'cfg(feature, values("all_lane_counts"))', +] From 0734ae22f5e821023155e2df24628a1c6df54f2e Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Sun, 19 May 2024 23:14:48 +0000 Subject: [PATCH 2/6] Update check-cfg lists for alloc --- library/alloc/Cargo.toml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/library/alloc/Cargo.toml b/library/alloc/Cargo.toml index 2e7fcb9dbd35f..cddf87a92c502 100644 --- a/library/alloc/Cargo.toml +++ b/library/alloc/Cargo.toml @@ -40,3 +40,12 @@ 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" +check-cfg = [ + 'cfg(no_global_oom_handling)', + 'cfg(bootstrap)', + 'cfg(no_rc)', + 'cfg(no_sync)', +] From 73602bf4088b31daa0da10d3ea926e1145faa5d5 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Sun, 19 May 2024 23:27:41 +0000 Subject: [PATCH 3/6] Update check-cfg lists for std --- library/std/Cargo.toml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/library/std/Cargo.toml b/library/std/Cargo.toml index 5b36867fe2436..4b8ee4c130918 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"))', +] From c7d2f4592fb19a8c3d7ae5e6a1594edb4608c75f Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Mon, 20 May 2024 15:06:14 +0000 Subject: [PATCH 4/6] addresss reviews --- library/alloc/Cargo.toml | 5 ++++- library/core/Cargo.toml | 6 +++++- src/bootstrap/src/lib.rs | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/library/alloc/Cargo.toml b/library/alloc/Cargo.toml index cddf87a92c502..3960f71681264 100644 --- a/library/alloc/Cargo.toml +++ b/library/alloc/Cargo.toml @@ -43,9 +43,12 @@ 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(no_global_oom_handling)', '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 0c86f430f3250..756f68e604805 100644 --- a/library/core/Cargo.toml +++ b/library/core/Cargo.toml @@ -39,9 +39,13 @@ 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(no_fp_fmt_parse)', 'cfg(bootstrap)', 'cfg(stdarch_intel_sde)', - 'cfg(feature, values("all_lane_counts"))', + # This matches `EXTRA_CHECK_CFGS` in `src/bootstrap/src/lib.rs`. + 'cfg(feature, values(any()))', ] diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index 698a576effa63..0578638de5ce2 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -84,6 +84,7 @@ const EXTRA_CHECK_CFGS: &[(Option, &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. (Some(Mode::Std), "stdarch_intel_sde", None), (Some(Mode::Std), "no_fp_fmt_parse", None), (Some(Mode::Std), "no_global_oom_handling", None), From df3a32066fe4d9a1c8f922d7abfa5f76578a876a Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Mon, 20 May 2024 15:08:28 +0000 Subject: [PATCH 5/6] tidy alphabetica --- library/core/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/Cargo.toml b/library/core/Cargo.toml index 756f68e604805..daf2612833ddc 100644 --- a/library/core/Cargo.toml +++ b/library/core/Cargo.toml @@ -43,8 +43,8 @@ level = "warn" # 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(no_fp_fmt_parse)', '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()))', From 30e0ab84f985d4da0f9eb802e047f5462f4a8a65 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Tue, 21 May 2024 09:30:43 +0000 Subject: [PATCH 6/6] maybe replace check-cfg values in bootstrap with ones in Cargo.toml --- src/bootstrap/src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index 0578638de5ce2..38de5e3800005 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -85,6 +85,8 @@ const EXTRA_CHECK_CFGS: &[(Option, &str, Option<&[&'static str]>)] = &[ (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),