Skip to content

Commit 8a26a8b

Browse files
Rollup merge of rust-lang#133710 - Urgau:target_feature-merge-conflitcs, r=jieyouxu
Reducing `target_feature` check-cfg merge conflicts It was rightfully pointed in rust-lang#133099 (comment) that the expected values for the `target_feature` cfg are regularly updated and unfortunately the check-cfg tests for it are very merge-conflict prone. This PR aims at drastically reducing the likely-hood of those, by normalizing the "and X more" diagnostic, as well as making the full expected list multi-line instead of being on a single one. cc `@RalfJung` r? `@jieyouxu`
2 parents 7d67af9 + 43bed16 commit 8a26a8b

9 files changed

+346
-24
lines changed

Diff for: src/tools/compiletest/src/header.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1125,6 +1125,8 @@ fn parse_normalize_rule(header: &str) -> Option<(String, String)> {
11251125
.captures(header)?;
11261126
let regex = captures["regex"].to_owned();
11271127
let replacement = captures["replacement"].to_owned();
1128+
// FIXME: Support escaped new-line in strings.
1129+
let replacement = replacement.replace("\\n", "\n");
11281130
Some((regex, replacement))
11291131
}
11301132

Diff for: tests/ui/check-cfg/and-more-diagnostic.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// This test makes sure that we don't emit a long list of possible values
2+
// but that we stop at a fix point and say "and X more".
3+
//
4+
//@ check-pass
5+
//@ no-auto-check-cfg
6+
//@ compile-flags: --check-cfg=cfg()
7+
//@ normalize-stderr-test: "and \d+ more" -> "and X more"
8+
//@ normalize-stderr-test: "`[a-zA-Z0-9_-]+`" -> "`xxx`"
9+
10+
fn main() {
11+
cfg!(target_feature = "zebra");
12+
//~^ WARNING unexpected `cfg` condition value
13+
}

Diff for: tests/ui/check-cfg/and-more-diagnostic.stderr

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
warning: unexpected `xxx` condition value: `xxx`
2+
--> $DIR/and-more-diagnostic.rs:11:10
3+
|
4+
LL | cfg!(target_feature = "zebra");
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= 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
8+
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
9+
= note: `#[warn(unexpected_cfgs)]` on by default
10+
11+
warning: 1 warning emitted
12+

Diff for: tests/ui/check-cfg/mix.rs

-2
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ fn test_cfg_macro() {
7575
//~^ WARNING unexpected `cfg` condition value
7676
//~| WARNING unexpected `cfg` condition value
7777
//~| WARNING unexpected `cfg` condition value
78-
cfg!(target_feature = "zebra");
79-
//~^ WARNING unexpected `cfg` condition value
8078
}
8179

8280
fn main() {}

Diff for: tests/ui/check-cfg/mix.stderr

+1-10
Original file line numberDiff line numberDiff line change
@@ -245,14 +245,5 @@ LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra"));
245245
= help: to expect this configuration use `--check-cfg=cfg(feature, values("zebra"))`
246246
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
247247

248-
warning: unexpected `cfg` condition value: `zebra`
249-
--> $DIR/mix.rs:78:10
250-
|
251-
LL | cfg!(target_feature = "zebra");
252-
| ^^^^^^^^^^^^^^^^^^^^^^^^
253-
|
254-
= 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
255-
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
256-
257-
warning: 27 warnings emitted
248+
warning: 26 warnings emitted
258249

Diff for: tests/ui/check-cfg/target_feature.rs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// This test prints all the possible values for the `target_feature` cfg
2+
// as a way to assert the expected values and reflect on any changes made
3+
// to the `target_feature` cfg in the compiler.
4+
//
5+
// The output of this test does not reflect the actual output seen by
6+
// users which will see a truncated list of possible values (at worst).
7+
//
8+
// In case of test output differences, just `--bless` the test.
9+
//
10+
//@ check-pass
11+
//@ no-auto-check-cfg
12+
//@ compile-flags: --check-cfg=cfg() -Zcheck-cfg-all-expected
13+
//@ normalize-stderr-test: "`, `" -> "`\n`"
14+
15+
fn main() {
16+
cfg!(target_feature = "_UNEXPECTED_VALUE");
17+
//~^ WARNING unexpected `cfg` condition value
18+
}

Diff for: tests/ui/check-cfg/target_feature.stderr

+297
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,297 @@
1+
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
2+
--> $DIR/target_feature.rs:16:10
3+
|
4+
LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: expected values for `target_feature` are: `10e60`
8+
`2e3`
9+
`3e3r1`
10+
`3e3r2`
11+
`3e3r3`
12+
`3e7`
13+
`7e10`
14+
`a`
15+
`aclass`
16+
`adx`
17+
`aes`
18+
`altivec`
19+
`alu32`
20+
`amx-bf16`
21+
`amx-complex`
22+
`amx-fp16`
23+
`amx-int8`
24+
`amx-tile`
25+
`atomics`
26+
`avx`
27+
`avx2`
28+
`avx512bf16`
29+
`avx512bitalg`
30+
`avx512bw`
31+
`avx512cd`
32+
`avx512dq`
33+
`avx512f`
34+
`avx512fp16`
35+
`avx512ifma`
36+
`avx512vbmi`
37+
`avx512vbmi2`
38+
`avx512vl`
39+
`avx512vnni`
40+
`avx512vp2intersect`
41+
`avx512vpopcntdq`
42+
`avxifma`
43+
`avxneconvert`
44+
`avxvnni`
45+
`avxvnniint16`
46+
`avxvnniint8`
47+
`backchain`
48+
`bf16`
49+
`bmi1`
50+
`bmi2`
51+
`bti`
52+
`bulk-memory`
53+
`c`
54+
`cache`
55+
`cmpxchg16b`
56+
`crc`
57+
`crt-static`
58+
`cssc`
59+
`d`
60+
`d32`
61+
`dit`
62+
`doloop`
63+
`dotprod`
64+
`dpb`
65+
`dpb2`
66+
`dsp`
67+
`dsp1e2`
68+
`dspe60`
69+
`e`
70+
`e1`
71+
`e2`
72+
`ecv`
73+
`edsp`
74+
`elrw`
75+
`ermsb`
76+
`exception-handling`
77+
`extended-const`
78+
`f`
79+
`f16c`
80+
`f32mm`
81+
`f64mm`
82+
`faminmax`
83+
`fcma`
84+
`fdivdu`
85+
`fhm`
86+
`flagm`
87+
`flagm2`
88+
`float1e2`
89+
`float1e3`
90+
`float3e4`
91+
`float7e60`
92+
`floate1`
93+
`fma`
94+
`fp-armv8`
95+
`fp16`
96+
`fp64`
97+
`fp8`
98+
`fp8dot2`
99+
`fp8dot4`
100+
`fp8fma`
101+
`fpuv2_df`
102+
`fpuv2_sf`
103+
`fpuv3_df`
104+
`fpuv3_hf`
105+
`fpuv3_hi`
106+
`fpuv3_sf`
107+
`frecipe`
108+
`frintts`
109+
`fxsr`
110+
`gfni`
111+
`hard-float`
112+
`hard-float-abi`
113+
`hard-tp`
114+
`hbc`
115+
`high-registers`
116+
`hvx`
117+
`hvx-length128b`
118+
`hwdiv`
119+
`i8mm`
120+
`jsconv`
121+
`lahfsahf`
122+
`lasx`
123+
`lbt`
124+
`leoncasa`
125+
`lor`
126+
`lse`
127+
`lse128`
128+
`lse2`
129+
`lsx`
130+
`lut`
131+
`lvz`
132+
`lzcnt`
133+
`m`
134+
`mclass`
135+
`mops`
136+
`movbe`
137+
`mp`
138+
`mp1e2`
139+
`msa`
140+
`mte`
141+
`multivalue`
142+
`mutable-globals`
143+
`neon`
144+
`nontrapping-fptoint`
145+
`nvic`
146+
`paca`
147+
`pacg`
148+
`pan`
149+
`partword-atomics`
150+
`pauth-lr`
151+
`pclmulqdq`
152+
`pmuv3`
153+
`popcnt`
154+
`power10-vector`
155+
`power8-altivec`
156+
`power8-vector`
157+
`power9-altivec`
158+
`power9-vector`
159+
`prfchw`
160+
`quadword-atomics`
161+
`rand`
162+
`ras`
163+
`rclass`
164+
`rcpc`
165+
`rcpc2`
166+
`rcpc3`
167+
`rdm`
168+
`rdrand`
169+
`rdseed`
170+
`reference-types`
171+
`relax`
172+
`relaxed-simd`
173+
`reserve-x18`
174+
`rtm`
175+
`sb`
176+
`sha`
177+
`sha2`
178+
`sha3`
179+
`sha512`
180+
`sign-ext`
181+
`simd128`
182+
`sm3`
183+
`sm4`
184+
`sme`
185+
`sme-b16b16`
186+
`sme-f16f16`
187+
`sme-f64f64`
188+
`sme-f8f16`
189+
`sme-f8f32`
190+
`sme-fa64`
191+
`sme-i16i64`
192+
`sme-lutv2`
193+
`sme2`
194+
`sme2p1`
195+
`spe`
196+
`ssbs`
197+
`sse`
198+
`sse2`
199+
`sse3`
200+
`sse4.1`
201+
`sse4.2`
202+
`sse4a`
203+
`ssse3`
204+
`ssve-fp8dot2`
205+
`ssve-fp8dot4`
206+
`ssve-fp8fma`
207+
`sve`
208+
`sve-b16b16`
209+
`sve2`
210+
`sve2-aes`
211+
`sve2-bitperm`
212+
`sve2-sha3`
213+
`sve2-sm4`
214+
`sve2p1`
215+
`tail-call`
216+
`tbm`
217+
`thumb-mode`
218+
`thumb2`
219+
`tme`
220+
`trust`
221+
`trustzone`
222+
`ual`
223+
`unaligned-scalar-mem`
224+
`v`
225+
`v5te`
226+
`v6`
227+
`v6k`
228+
`v6t2`
229+
`v7`
230+
`v8`
231+
`v8.1a`
232+
`v8.2a`
233+
`v8.3a`
234+
`v8.4a`
235+
`v8.5a`
236+
`v8.6a`
237+
`v8.7a`
238+
`v8.8a`
239+
`v8.9a`
240+
`v8plus`
241+
`v9`
242+
`v9.1a`
243+
`v9.2a`
244+
`v9.3a`
245+
`v9.4a`
246+
`v9.5a`
247+
`v9a`
248+
`vaes`
249+
`vdsp2e60f`
250+
`vdspv1`
251+
`vdspv2`
252+
`vector`
253+
`vfp2`
254+
`vfp3`
255+
`vfp4`
256+
`vh`
257+
`virt`
258+
`virtualization`
259+
`vpclmulqdq`
260+
`vsx`
261+
`wfxt`
262+
`wide-arithmetic`
263+
`xop`
264+
`xsave`
265+
`xsavec`
266+
`xsaveopt`
267+
`xsaves`
268+
`zaamo`
269+
`zabha`
270+
`zalrsc`
271+
`zba`
272+
`zbb`
273+
`zbc`
274+
`zbkb`
275+
`zbkc`
276+
`zbkx`
277+
`zbs`
278+
`zdinx`
279+
`zfh`
280+
`zfhmin`
281+
`zfinx`
282+
`zhinx`
283+
`zhinxmin`
284+
`zk`
285+
`zkn`
286+
`zknd`
287+
`zkne`
288+
`zknh`
289+
`zkr`
290+
`zks`
291+
`zksed`
292+
`zksh`, and `zkt`
293+
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
294+
= note: `#[warn(unexpected_cfgs)]` on by default
295+
296+
warning: 1 warning emitted
297+

Diff for: tests/ui/check-cfg/well-known-values.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@
6060
//~^ WARN unexpected `cfg` condition value
6161
target_family = "_UNEXPECTED_VALUE",
6262
//~^ WARN unexpected `cfg` condition value
63-
target_feature = "_UNEXPECTED_VALUE",
64-
//~^ WARN unexpected `cfg` condition value
63+
// target_feature = "_UNEXPECTED_VALUE",
64+
// ^ tested in target_feature.rs
6565
target_has_atomic = "_UNEXPECTED_VALUE",
6666
//~^ WARN unexpected `cfg` condition value
6767
target_has_atomic_equal_alignment = "_UNEXPECTED_VALUE",

0 commit comments

Comments
 (0)