Skip to content

Commit 1739793

Browse files
committed
Enable conditional checking of values in the Rust codebase
1 parent e3ea59a commit 1739793

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/bootstrap/builder.rs

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

11031103
// Enable cfg checking of rustc well-known names
1104-
rustflags.arg("-Zunstable-options").arg("--check-cfg=names()");
1104+
rustflags
1105+
.arg("-Zunstable-options")
1106+
// Enable checking of well known names
1107+
.arg("--check-cfg=names()")
1108+
// Enable checking of well known values
1109+
.arg("--check-cfg=values()");
11051110

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

src/bootstrap/lib.rs

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

0 commit comments

Comments
 (0)