Skip to content

Commit 21b0325

Browse files
committed
Auto merge of rust-lang#94738 - Urgau:rustbuild-check-cfg-values, r=Mark-Simulacrum
Enable conditional checking of values in the Rust codebase This pull-request enable conditional checking of (well known) values in the Rust codebase. Well known values were added in rust-lang#94362. All the `target_*` values are taken from all the built-in targets which is why some extra values were needed do be added as they are not (yet ?) defined in any built-in targets. r? `@Mark-Simulacrum`
2 parents ebed06f + 1739793 commit 21b0325

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

library/core/tests/iter/adapters/step_by.rs

-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ fn test_iterator_step_by_nth() {
5050

5151
#[test]
5252
fn test_iterator_step_by_nth_overflow() {
53-
#[cfg(target_pointer_width = "8")]
54-
type Bigger = u16;
5553
#[cfg(target_pointer_width = "16")]
5654
type Bigger = u32;
5755
#[cfg(target_pointer_width = "32")]

src/bootstrap/builder.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,12 @@ impl<'a> Builder<'a> {
10971097
// cargo.arg("-Zcheck-cfg-features");
10981098

10991099
// Enable cfg checking of rustc well-known names
1100-
rustflags.arg("-Zunstable-options").arg("--check-cfg=names()");
1100+
rustflags
1101+
.arg("-Zunstable-options")
1102+
// Enable checking of well known names
1103+
.arg("--check-cfg=names()")
1104+
// Enable checking of well known values
1105+
.arg("--check-cfg=values()");
11011106

11021107
// Add extra cfg not defined in rustc
11031108
for (restricted_mode, name, values) in EXTRA_CHECK_CFGS {

src/bootstrap/lib.rs

+9
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,15 @@ const EXTRA_CHECK_CFGS: &[(Option<Mode>, &'static str, Option<&[&'static str]>)]
198198
(Some(Mode::Std), "no_global_oom_handling", None),
199199
(Some(Mode::Std), "freebsd12", None),
200200
(Some(Mode::Std), "backtrace_in_libstd", None),
201+
/* Extra values not defined in the built-in targets yet, but used in std */
202+
(Some(Mode::Std), "target_env", Some(&["libnx"])),
203+
(Some(Mode::Std), "target_os", Some(&["watchos"])),
204+
(
205+
Some(Mode::Std),
206+
"target_arch",
207+
Some(&["asmjs", "spirv", "nvptx", "nvptx64", "le32", "xtensa"]),
208+
),
209+
/* Extra names used by dependencies */
201210
// FIXME: Used by rustfmt is their test but is invalid (neither cargo nor bootstrap ever set
202211
// this config) should probably by removed or use a allow attribute.
203212
(Some(Mode::ToolRustc), "release", None),

0 commit comments

Comments
 (0)