about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-03-13 18:34:00 +0000
committerbors <bors@rust-lang.org>2022-03-13 18:34:00 +0000
commit21b0325c68421b00c6c91055ac330bd5ffe1ea6b (patch)
tree83688316d811b1378da12696305306604bdf0a43
parentebed06fcba3b58913a5087039a81478d43b47b2f (diff)
parent17397934d3ab9385c439e6001f561aff4f9a7110 (diff)
downloadrust-21b0325c68421b00c6c91055ac330bd5ffe1ea6b.tar.gz
rust-21b0325c68421b00c6c91055ac330bd5ffe1ea6b.zip
Auto merge of #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 https://github.com/rust-lang/rust/pull/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`
-rw-r--r--library/core/tests/iter/adapters/step_by.rs2
-rw-r--r--src/bootstrap/builder.rs7
-rw-r--r--src/bootstrap/lib.rs9
3 files changed, 15 insertions, 3 deletions
diff --git a/library/core/tests/iter/adapters/step_by.rs b/library/core/tests/iter/adapters/step_by.rs
index 6502c7fb795..94f2fa8c25e 100644
--- a/library/core/tests/iter/adapters/step_by.rs
+++ b/library/core/tests/iter/adapters/step_by.rs
@@ -50,8 +50,6 @@ fn test_iterator_step_by_nth() {
 
 #[test]
 fn test_iterator_step_by_nth_overflow() {
-    #[cfg(target_pointer_width = "8")]
-    type Bigger = u16;
     #[cfg(target_pointer_width = "16")]
     type Bigger = u32;
     #[cfg(target_pointer_width = "32")]
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
index 68ae7f2be96..0232446b1f7 100644
--- a/src/bootstrap/builder.rs
+++ b/src/bootstrap/builder.rs
@@ -1097,7 +1097,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 {
diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
index 2ee67d623ee..41e2e976162 100644
--- a/src/bootstrap/lib.rs
+++ b/src/bootstrap/lib.rs
@@ -198,6 +198,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),