about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUrgau <urgau@numericable.fr>2024-11-29 18:04:36 +0100
committerUrgau <urgau@numericable.fr>2024-12-01 20:51:52 +0100
commit85e476556b5c3622ef5356f31b724d2c2b5d2a1d (patch)
tree6c1a9313a6f5027d54444f35286921aade20c7a5
parentca4e54f032a49a23883c429ab34911ed856973c2 (diff)
downloadrust-85e476556b5c3622ef5356f31b724d2c2b5d2a1d.tar.gz
rust-85e476556b5c3622ef5356f31b724d2c2b5d2a1d.zip
Add specific test for check-cfg "and X more" diagnostic
-rw-r--r--tests/ui/check-cfg/and-more-diagnostic.rs13
-rw-r--r--tests/ui/check-cfg/and-more-diagnostic.stderr12
-rw-r--r--tests/ui/check-cfg/mix.rs2
-rw-r--r--tests/ui/check-cfg/mix.stderr11
4 files changed, 26 insertions, 12 deletions
diff --git a/tests/ui/check-cfg/and-more-diagnostic.rs b/tests/ui/check-cfg/and-more-diagnostic.rs
new file mode 100644
index 00000000000..82867f3b435
--- /dev/null
+++ b/tests/ui/check-cfg/and-more-diagnostic.rs
@@ -0,0 +1,13 @@
+// This test makes sure that we don't emit a long list of possible values
+// but that we stop at a fix point and say "and X more".
+//
+//@ check-pass
+//@ no-auto-check-cfg
+//@ compile-flags: --check-cfg=cfg()
+//@ normalize-stderr-test: "and \d+ more" -> "and X more"
+//@ normalize-stderr-test: "`[a-zA-Z0-9_-]+`" -> "`xxx`"
+
+fn main() {
+    cfg!(target_feature = "zebra");
+    //~^ WARNING unexpected `cfg` condition value
+}
diff --git a/tests/ui/check-cfg/and-more-diagnostic.stderr b/tests/ui/check-cfg/and-more-diagnostic.stderr
new file mode 100644
index 00000000000..2ac80c84c37
--- /dev/null
+++ b/tests/ui/check-cfg/and-more-diagnostic.stderr
@@ -0,0 +1,12 @@
+warning: unexpected `xxx` condition value: `xxx`
+  --> $DIR/and-more-diagnostic.rs:11:10
+   |
+LL |     cfg!(target_feature = "zebra");
+   |          ^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: expected values for `xxx` are: `xxx`, `xxx`, `xxx`, `xxx`, `xxx`, `xxx`, `xxx`, `xxx`, `xxx`, `xxx`, `xxx`, `xxx`, `xxx`, `xxx`, `xxx`, `xxx`, `xxx`, `xxx`, `xxx`, `xxx`, `xxx`, `xxx`, `xxx`, `xxx`, `xxx`, `xxx`, `xxx`, `xxx`, `xxx`, `xxx`, `xxx`, `xxx`, `xxx`, `xxx`, and `xxx` and X more
+   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
+   = note: `#[warn(unexpected_cfgs)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/check-cfg/mix.rs b/tests/ui/check-cfg/mix.rs
index ac244f4fc09..e9a2de2f672 100644
--- a/tests/ui/check-cfg/mix.rs
+++ b/tests/ui/check-cfg/mix.rs
@@ -75,8 +75,6 @@ fn test_cfg_macro() {
     //~^ WARNING unexpected `cfg` condition value
     //~| WARNING unexpected `cfg` condition value
     //~| WARNING unexpected `cfg` condition value
-    cfg!(target_feature = "zebra");
-    //~^ WARNING unexpected `cfg` condition value
 }
 
 fn main() {}
diff --git a/tests/ui/check-cfg/mix.stderr b/tests/ui/check-cfg/mix.stderr
index 32eb01c7018..231236799c6 100644
--- a/tests/ui/check-cfg/mix.stderr
+++ b/tests/ui/check-cfg/mix.stderr
@@ -245,14 +245,5 @@ LL |     cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra"));
    = help: to expect this configuration use `--check-cfg=cfg(feature, values("zebra"))`
    = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
 
-warning: unexpected `cfg` condition value: `zebra`
-  --> $DIR/mix.rs:78:10
-   |
-LL |     cfg!(target_feature = "zebra");
-   |          ^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-   = note: expected values for `target_feature` are: `10e60`, `2e3`, `3e3r1`, `3e3r2`, `3e3r3`, `3e7`, `7e10`, `a`, `aclass`, `adx`, `aes`, `altivec`, `alu32`, `amx-bf16`, `amx-complex`, `amx-fp16`, `amx-int8`, `amx-tile`, `atomics`, `avx`, `avx2`, `avx512bf16`, `avx512bitalg`, `avx512bw`, `avx512cd`, `avx512dq`, `avx512f`, `avx512fp16`, `avx512ifma`, `avx512vbmi`, `avx512vbmi2`, `avx512vl`, `avx512vnni`, `avx512vp2intersect`, and `avx512vpopcntdq` and 252 more
-   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
-
-warning: 27 warnings emitted
+warning: 26 warnings emitted