Skip to content

Commit

Permalink
Enable conditional checking of values in the Rust codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
Urgau committed Mar 8, 2022
1 parent e3ea59a commit 1739793
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/bootstrap/builder.rs
Expand Up @@ -1101,7 +1101,12 @@ impl<'a> Builder<'a> {
// cargo.arg("-Zcheck-cfg-features");

// Enable cfg checking of rustc well-known names
rustflags.arg("-Zunstable-options").arg("--check-cfg=names()");
rustflags
.arg("-Zunstable-options")
// Enable checking of well known names
.arg("--check-cfg=names()")
// Enable checking of well known values
.arg("--check-cfg=values()");

// Add extra cfg not defined in rustc
for (restricted_mode, name, values) in EXTRA_CHECK_CFGS {
Expand Down
9 changes: 9 additions & 0 deletions src/bootstrap/lib.rs
Expand Up @@ -199,6 +199,15 @@ const EXTRA_CHECK_CFGS: &[(Option<Mode>, &'static str, Option<&[&'static str]>)]
(Some(Mode::Std), "no_global_oom_handling", None),
(Some(Mode::Std), "freebsd12", None),
(Some(Mode::Std), "backtrace_in_libstd", None),
/* Extra values not defined in the built-in targets yet, but used in std */
(Some(Mode::Std), "target_env", Some(&["libnx"])),
(Some(Mode::Std), "target_os", Some(&["watchos"])),
(
Some(Mode::Std),
"target_arch",
Some(&["asmjs", "spirv", "nvptx", "nvptx64", "le32", "xtensa"]),
),
/* Extra names used by dependencies */
// FIXME: Used by rustfmt is their test but is invalid (neither cargo nor bootstrap ever set
// this config) should probably by removed or use a allow attribute.
(Some(Mode::ToolRustc), "release", None),
Expand Down

0 comments on commit 1739793

Please sign in to comment.