Skip to content

Commit

Permalink
Add specific test for check-cfg "and X more" diagnostic
Browse files Browse the repository at this point in the history
  • Loading branch information
Urgau committed Dec 1, 2024
1 parent ca4e54f commit 85e4765
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
13 changes: 13 additions & 0 deletions tests/ui/check-cfg/and-more-diagnostic.rs
Original file line number Diff line number Diff line change
@@ -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
}
12 changes: 12 additions & 0 deletions tests/ui/check-cfg/and-more-diagnostic.stderr
Original file line number Diff line number Diff line change
@@ -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

2 changes: 0 additions & 2 deletions tests/ui/check-cfg/mix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
11 changes: 1 addition & 10 deletions tests/ui/check-cfg/mix.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 85e4765

Please sign in to comment.