summaryrefslogtreecommitdiffstats
path: root/tests/ui/check-cfg/well-known-values.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
commit9918693037dce8aa4bb6f08741b6812923486c18 (patch)
tree21d2b40bec7e6a7ea664acee056eb3d08e15a1cf /tests/ui/check-cfg/well-known-values.rs
parentReleasing progress-linux version 1.75.0+dfsg1-5~progress7.99u1. (diff)
downloadrustc-9918693037dce8aa4bb6f08741b6812923486c18.tar.xz
rustc-9918693037dce8aa4bb6f08741b6812923486c18.zip
Merging upstream version 1.76.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/check-cfg/well-known-values.rs')
-rw-r--r--tests/ui/check-cfg/well-known-values.rs109
1 files changed, 88 insertions, 21 deletions
diff --git a/tests/ui/check-cfg/well-known-values.rs b/tests/ui/check-cfg/well-known-values.rs
index 8b56c8729..21268bf10 100644
--- a/tests/ui/check-cfg/well-known-values.rs
+++ b/tests/ui/check-cfg/well-known-values.rs
@@ -1,41 +1,108 @@
-// This test check that we lint on non well known values and that we don't lint on well known
-// values
+// This test check that we recognize all the well known config names
+// and that we correctly lint on unexpected values.
+//
+// This test also serve as an "anti-regression" for the well known
+// values since the suggestion shows them.
//
// check-pass
// compile-flags: --check-cfg=cfg() -Z unstable-options
-#[cfg(target_os = "linuz")]
+#![feature(cfg_overflow_checks)]
+#![feature(cfg_relocation_model)]
+#![feature(cfg_sanitize)]
+#![feature(cfg_target_abi)]
+#![feature(cfg_target_has_atomic)]
+#![feature(cfg_target_has_atomic_equal_alignment)]
+#![feature(cfg_target_thread_local)]
+
+// This part makes sure that none of the well known names are
+// unexpected.
+//
+// BUT to make sure that no expected values changes without
+// being noticed we pass them a obviously wrong value so the
+// diagnostic prints the list of expected values.
+#[cfg(any(
+ // tidy-alphabetical-start
+ debug_assertions = "_UNEXPECTED_VALUE",
+ //~^ WARN unexpected `cfg` condition value
+ doc = "_UNEXPECTED_VALUE",
+ //~^ WARN unexpected `cfg` condition value
+ doctest = "_UNEXPECTED_VALUE",
+ //~^ WARN unexpected `cfg` condition value
+ miri = "_UNEXPECTED_VALUE",
+ //~^ WARN unexpected `cfg` condition value
+ overflow_checks = "_UNEXPECTED_VALUE",
+ //~^ WARN unexpected `cfg` condition value
+ panic = "_UNEXPECTED_VALUE",
+ //~^ WARN unexpected `cfg` condition value
+ proc_macro = "_UNEXPECTED_VALUE",
+ //~^ WARN unexpected `cfg` condition value
+ relocation_model = "_UNEXPECTED_VALUE",
+ //~^ WARN unexpected `cfg` condition value
+ sanitize = "_UNEXPECTED_VALUE",
+ //~^ WARN unexpected `cfg` condition value
+ target_abi = "_UNEXPECTED_VALUE",
+ //~^ WARN unexpected `cfg` condition value
+ target_arch = "_UNEXPECTED_VALUE",
+ //~^ WARN unexpected `cfg` condition value
+ target_endian = "_UNEXPECTED_VALUE",
+ //~^ WARN unexpected `cfg` condition value
+ target_env = "_UNEXPECTED_VALUE",
+ //~^ WARN unexpected `cfg` condition value
+ target_family = "_UNEXPECTED_VALUE",
+ //~^ WARN unexpected `cfg` condition value
+ target_feature = "_UNEXPECTED_VALUE",
+ //~^ WARN unexpected `cfg` condition value
+ target_has_atomic = "_UNEXPECTED_VALUE",
+ //~^ WARN unexpected `cfg` condition value
+ target_has_atomic_equal_alignment = "_UNEXPECTED_VALUE",
+ //~^ WARN unexpected `cfg` condition value
+ target_has_atomic_load_store = "_UNEXPECTED_VALUE",
+ //~^ WARN unexpected `cfg` condition value
+ target_os = "_UNEXPECTED_VALUE",
+ //~^ WARN unexpected `cfg` condition value
+ target_pointer_width = "_UNEXPECTED_VALUE",
+ //~^ WARN unexpected `cfg` condition value
+ target_thread_local = "_UNEXPECTED_VALUE",
+ //~^ WARN unexpected `cfg` condition value
+ target_vendor = "_UNEXPECTED_VALUE",
+ //~^ WARN unexpected `cfg` condition value
+ test = "_UNEXPECTED_VALUE",
+ //~^ WARN unexpected `cfg` condition value
+ unix = "_UNEXPECTED_VALUE",
+ //~^ WARN unexpected `cfg` condition value
+ windows = "_UNEXPECTED_VALUE",
+ //~^ WARN unexpected `cfg` condition value
+ // tidy-alphabetical-end
+))]
+fn unexpected_values() {}
+
+#[cfg(target_os = "linuz")] // testing that we suggest `linux`
//~^ WARNING unexpected `cfg` condition value
fn target_os_linux_misspell() {}
+// The #[cfg]s below serve as a safeguard to make sure we
+// don't lint when using an expected well-known name and
+// value, only a small subset of all possible expected
+// configs are tested, since we already test the names
+// above and don't need to test all values, just different
+// combinations (without value, with value, both...).
+
#[cfg(target_os = "linux")]
fn target_os_linux() {}
-#[cfg(target_has_atomic = "0")]
-//~^ WARNING unexpected `cfg` condition value
-fn target_has_atomic_invalid() {}
+#[cfg(target_feature = "crt-static")] // pure rustc feature
+fn target_feature() {}
#[cfg(target_has_atomic = "8")]
-fn target_has_atomic() {}
+fn target_has_atomic_8() {}
-#[cfg(unix = "aa")]
-//~^ WARNING unexpected `cfg` condition value
-fn unix_with_value() {}
+#[cfg(target_has_atomic)]
+fn target_has_atomic() {}
#[cfg(unix)]
fn unix() {}
-#[cfg(miri = "miri")]
-//~^ WARNING unexpected `cfg` condition value
-fn miri_with_value() {}
-
-#[cfg(miri)]
-fn miri() {}
-
-#[cfg(doc = "linux")]
-//~^ WARNING unexpected `cfg` condition value
-fn doc_with_value() {}
-
#[cfg(doc)]
fn doc() {}