check-cfg: mention the unexpected name and value in the primary message

This commit is contained in:
Urgau 2023-10-12 16:49:56 +02:00
parent 72815dc08f
commit dcfc484b09
17 changed files with 62 additions and 58 deletions

View File

@ -548,7 +548,11 @@ pub fn cfg_matches(
UNEXPECTED_CFGS,
cfg.span,
lint_node_id,
"unexpected `cfg` condition value",
if let Some(value) = cfg.value {
format!("unexpected `cfg` condition value: `{value}`")
} else {
format!("unexpected `cfg` condition value: (none)")
},
BuiltinLintDiagnostics::UnexpectedCfgValue(
(cfg.name, cfg.name_span),
cfg.value.map(|v| (v, cfg.value_span.unwrap())),
@ -560,7 +564,7 @@ pub fn cfg_matches(
UNEXPECTED_CFGS,
cfg.span,
lint_node_id,
"unexpected `cfg` condition name",
format!("unexpected `cfg` condition name: `{}`", cfg.name),
BuiltinLintDiagnostics::UnexpectedCfgName(
(cfg.name, cfg.name_span),
cfg.value.map(|v| (v, cfg.value_span.unwrap())),

View File

@ -1,4 +1,4 @@
warning: unexpected `cfg` condition name
warning: unexpected `cfg` condition name: `FALSE`
--> $DIR/allow-same-level.rs:7:7
|
LL | #[cfg(FALSE)]

View File

@ -1,4 +1,4 @@
warning: unexpected `cfg` condition name
warning: unexpected `cfg` condition name: `target_architecture`
--> $DIR/compact-names.rs:11:28
|
LL | #[cfg(target(os = "linux", architecture = "arm"))]

View File

@ -1,4 +1,4 @@
warning: unexpected `cfg` condition value
warning: unexpected `cfg` condition value: `X`
--> $DIR/compact-values.rs:11:28
|
LL | #[cfg(target(os = "linux", arch = "X"))]

View File

@ -1,4 +1,4 @@
warning: unexpected `cfg` condition name
warning: unexpected `cfg` condition name: `featur`
--> $DIR/diagnotics.rs:4:7
|
LL | #[cfg(featur)]
@ -7,7 +7,7 @@ LL | #[cfg(featur)]
= help: expected values for `feature` are: `foo`
= note: `#[warn(unexpected_cfgs)]` on by default
warning: unexpected `cfg` condition name
warning: unexpected `cfg` condition name: `featur`
--> $DIR/diagnotics.rs:8:7
|
LL | #[cfg(featur = "foo")]
@ -18,7 +18,7 @@ help: there is a config with a similar name and value
LL | #[cfg(feature = "foo")]
| ~~~~~~~
warning: unexpected `cfg` condition name
warning: unexpected `cfg` condition name: `featur`
--> $DIR/diagnotics.rs:12:7
|
LL | #[cfg(featur = "fo")]
@ -30,13 +30,13 @@ help: there is a config with a similar name and different values
LL | #[cfg(feature = "foo")]
| ~~~~~~~~~~~~~~~
warning: unexpected `cfg` condition name
warning: unexpected `cfg` condition name: `no_value`
--> $DIR/diagnotics.rs:19:7
|
LL | #[cfg(no_value)]
| ^^^^^^^^ help: there is a config with a similar name: `no_values`
warning: unexpected `cfg` condition name
warning: unexpected `cfg` condition name: `no_value`
--> $DIR/diagnotics.rs:23:7
|
LL | #[cfg(no_value = "foo")]
@ -47,7 +47,7 @@ help: there is a config with a similar name and no value
LL | #[cfg(no_values)]
| ~~~~~~~~~
warning: unexpected `cfg` condition value
warning: unexpected `cfg` condition value: `bar`
--> $DIR/diagnotics.rs:27:7
|
LL | #[cfg(no_values = "bar")]

View File

@ -1,4 +1,4 @@
warning: unexpected `cfg` condition name
warning: unexpected `cfg` condition name: `unknown_key`
--> $DIR/empty-names.rs:6:7
|
LL | #[cfg(unknown_key = "value")]

View File

@ -1,4 +1,4 @@
warning: unexpected `cfg` condition value
warning: unexpected `cfg` condition value: `value`
--> $DIR/empty-values.rs:6:7
|
LL | #[cfg(test = "value")]

View File

@ -1,4 +1,4 @@
warning: unexpected `cfg` condition name
warning: unexpected `cfg` condition name: `widnows`
--> $DIR/invalid-cfg-name.rs:7:7
|
LL | #[cfg(widnows)]

View File

@ -1,4 +1,4 @@
warning: unexpected `cfg` condition value
warning: unexpected `cfg` condition value: `sedre`
--> $DIR/invalid-cfg-value.rs:7:7
|
LL | #[cfg(feature = "sedre")]
@ -9,7 +9,7 @@ LL | #[cfg(feature = "sedre")]
= note: expected values for `feature` are: `full`, `serde`
= note: `#[warn(unexpected_cfgs)]` on by default
warning: unexpected `cfg` condition value
warning: unexpected `cfg` condition value: `rand`
--> $DIR/invalid-cfg-value.rs:14:7
|
LL | #[cfg(feature = "rand")]

View File

@ -1,4 +1,4 @@
warning: unexpected `cfg` condition name
warning: unexpected `cfg` condition name: `widnows`
--> $DIR/mix.rs:11:7
|
LL | #[cfg(widnows)]
@ -6,7 +6,7 @@ LL | #[cfg(widnows)]
|
= note: `#[warn(unexpected_cfgs)]` on by default
warning: unexpected `cfg` condition value
warning: unexpected `cfg` condition value: (none)
--> $DIR/mix.rs:15:7
|
LL | #[cfg(feature)]
@ -14,7 +14,7 @@ LL | #[cfg(feature)]
|
= note: expected values for `feature` are: `foo`
warning: unexpected `cfg` condition value
warning: unexpected `cfg` condition value: `bar`
--> $DIR/mix.rs:22:7
|
LL | #[cfg(feature = "bar")]
@ -22,7 +22,7 @@ LL | #[cfg(feature = "bar")]
|
= note: expected values for `feature` are: `foo`
warning: unexpected `cfg` condition value
warning: unexpected `cfg` condition value: `zebra`
--> $DIR/mix.rs:26:7
|
LL | #[cfg(feature = "zebra")]
@ -30,7 +30,7 @@ LL | #[cfg(feature = "zebra")]
|
= note: expected values for `feature` are: `foo`
warning: unexpected `cfg` condition name
warning: unexpected `cfg` condition name: `uu`
--> $DIR/mix.rs:30:12
|
LL | #[cfg_attr(uu, test)]
@ -46,13 +46,13 @@ warning: unexpected `unknown_name` as condition name
|
= help: was set with `--cfg` but isn't in the `--check-cfg` expected names
warning: unexpected `cfg` condition name
warning: unexpected `cfg` condition name: `widnows`
--> $DIR/mix.rs:39:10
|
LL | cfg!(widnows);
| ^^^^^^^ help: there is a config with a similar name: `windows`
warning: unexpected `cfg` condition value
warning: unexpected `cfg` condition value: `bar`
--> $DIR/mix.rs:42:10
|
LL | cfg!(feature = "bar");
@ -60,7 +60,7 @@ LL | cfg!(feature = "bar");
|
= note: expected values for `feature` are: `foo`
warning: unexpected `cfg` condition value
warning: unexpected `cfg` condition value: `zebra`
--> $DIR/mix.rs:44:10
|
LL | cfg!(feature = "zebra");
@ -68,7 +68,7 @@ LL | cfg!(feature = "zebra");
|
= note: expected values for `feature` are: `foo`
warning: unexpected `cfg` condition name
warning: unexpected `cfg` condition name: `xxx`
--> $DIR/mix.rs:46:10
|
LL | cfg!(xxx = "foo");
@ -76,7 +76,7 @@ LL | cfg!(xxx = "foo");
|
= help: expected names are: `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows`
warning: unexpected `cfg` condition name
warning: unexpected `cfg` condition name: `xxx`
--> $DIR/mix.rs:48:10
|
LL | cfg!(xxx);
@ -84,7 +84,7 @@ LL | cfg!(xxx);
|
= help: expected names are: `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows`
warning: unexpected `cfg` condition name
warning: unexpected `cfg` condition name: `xxx`
--> $DIR/mix.rs:50:14
|
LL | cfg!(any(xxx, windows));
@ -92,7 +92,7 @@ LL | cfg!(any(xxx, windows));
|
= help: expected names are: `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows`
warning: unexpected `cfg` condition value
warning: unexpected `cfg` condition value: `bad`
--> $DIR/mix.rs:52:14
|
LL | cfg!(any(feature = "bad", windows));
@ -100,7 +100,7 @@ LL | cfg!(any(feature = "bad", windows));
|
= note: expected values for `feature` are: `foo`
warning: unexpected `cfg` condition name
warning: unexpected `cfg` condition name: `xxx`
--> $DIR/mix.rs:54:23
|
LL | cfg!(any(windows, xxx));
@ -108,7 +108,7 @@ LL | cfg!(any(windows, xxx));
|
= help: expected names are: `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows`
warning: unexpected `cfg` condition name
warning: unexpected `cfg` condition name: `xxx`
--> $DIR/mix.rs:56:20
|
LL | cfg!(all(unix, xxx));
@ -116,7 +116,7 @@ LL | cfg!(all(unix, xxx));
|
= help: expected names are: `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows`
warning: unexpected `cfg` condition name
warning: unexpected `cfg` condition name: `aa`
--> $DIR/mix.rs:58:14
|
LL | cfg!(all(aa, bb));
@ -124,7 +124,7 @@ LL | cfg!(all(aa, bb));
|
= help: expected names are: `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows`
warning: unexpected `cfg` condition name
warning: unexpected `cfg` condition name: `bb`
--> $DIR/mix.rs:58:18
|
LL | cfg!(all(aa, bb));
@ -132,7 +132,7 @@ LL | cfg!(all(aa, bb));
|
= help: expected names are: `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows`
warning: unexpected `cfg` condition name
warning: unexpected `cfg` condition name: `aa`
--> $DIR/mix.rs:61:14
|
LL | cfg!(any(aa, bb));
@ -140,7 +140,7 @@ LL | cfg!(any(aa, bb));
|
= help: expected names are: `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows`
warning: unexpected `cfg` condition name
warning: unexpected `cfg` condition name: `bb`
--> $DIR/mix.rs:61:18
|
LL | cfg!(any(aa, bb));
@ -148,7 +148,7 @@ LL | cfg!(any(aa, bb));
|
= help: expected names are: `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows`
warning: unexpected `cfg` condition value
warning: unexpected `cfg` condition value: `zebra`
--> $DIR/mix.rs:64:20
|
LL | cfg!(any(unix, feature = "zebra"));
@ -156,7 +156,7 @@ LL | cfg!(any(unix, feature = "zebra"));
|
= note: expected values for `feature` are: `foo`
warning: unexpected `cfg` condition name
warning: unexpected `cfg` condition name: `xxx`
--> $DIR/mix.rs:66:14
|
LL | cfg!(any(xxx, feature = "zebra"));
@ -164,7 +164,7 @@ LL | cfg!(any(xxx, feature = "zebra"));
|
= help: expected names are: `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows`
warning: unexpected `cfg` condition value
warning: unexpected `cfg` condition value: `zebra`
--> $DIR/mix.rs:66:19
|
LL | cfg!(any(xxx, feature = "zebra"));
@ -172,7 +172,7 @@ LL | cfg!(any(xxx, feature = "zebra"));
|
= note: expected values for `feature` are: `foo`
warning: unexpected `cfg` condition name
warning: unexpected `cfg` condition name: `xxx`
--> $DIR/mix.rs:69:14
|
LL | cfg!(any(xxx, unix, xxx));
@ -180,7 +180,7 @@ LL | cfg!(any(xxx, unix, xxx));
|
= help: expected names are: `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows`
warning: unexpected `cfg` condition name
warning: unexpected `cfg` condition name: `xxx`
--> $DIR/mix.rs:69:25
|
LL | cfg!(any(xxx, unix, xxx));
@ -188,7 +188,7 @@ LL | cfg!(any(xxx, unix, xxx));
|
= help: expected names are: `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `unix`, `windows`
warning: unexpected `cfg` condition value
warning: unexpected `cfg` condition value: `zebra`
--> $DIR/mix.rs:72:14
|
LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra"));
@ -196,7 +196,7 @@ LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra"));
|
= note: expected values for `feature` are: `foo`
warning: unexpected `cfg` condition value
warning: unexpected `cfg` condition value: `zebra`
--> $DIR/mix.rs:72:33
|
LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra"));
@ -204,7 +204,7 @@ LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra"));
|
= note: expected values for `feature` are: `foo`
warning: unexpected `cfg` condition value
warning: unexpected `cfg` condition value: `zebra`
--> $DIR/mix.rs:72:52
|
LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra"));

View File

@ -1,4 +1,4 @@
warning: unexpected `cfg` condition value
warning: unexpected `cfg` condition value: `foo`
--> $DIR/no-values.rs:6:7
|
LL | #[cfg(feature = "foo")]
@ -9,7 +9,7 @@ LL | #[cfg(feature = "foo")]
= note: no expected value for `feature`
= note: `#[warn(unexpected_cfgs)]` on by default
warning: unexpected `cfg` condition value
warning: unexpected `cfg` condition value: `foo`
--> $DIR/no-values.rs:10:7
|
LL | #[cfg(test = "foo")]

View File

@ -1,4 +1,4 @@
warning: unexpected `cfg` condition value
warning: unexpected `cfg` condition value: (none)
--> $DIR/order-independant.rs:8:7
|
LL | #[cfg(a)]
@ -7,7 +7,7 @@ LL | #[cfg(a)]
= note: expected values for `a` are: `b`
= note: `#[warn(unexpected_cfgs)]` on by default
warning: unexpected `cfg` condition value
warning: unexpected `cfg` condition value: `unk`
--> $DIR/order-independant.rs:12:7
|
LL | #[cfg(a = "unk")]

View File

@ -1,4 +1,4 @@
warning: unexpected `cfg` condition value
warning: unexpected `cfg` condition value: (none)
--> $DIR/order-independant.rs:8:7
|
LL | #[cfg(a)]
@ -7,7 +7,7 @@ LL | #[cfg(a)]
= note: expected values for `a` are: `b`
= note: `#[warn(unexpected_cfgs)]` on by default
warning: unexpected `cfg` condition value
warning: unexpected `cfg` condition value: `unk`
--> $DIR/order-independant.rs:12:7
|
LL | #[cfg(a = "unk")]

View File

@ -1,4 +1,4 @@
warning: unexpected `cfg` condition name
warning: unexpected `cfg` condition name: `crossbeam_loom`
--> $DIR/stmt-no-ice.rs:7:11
|
LL | #[cfg(crossbeam_loom)]

View File

@ -1,4 +1,4 @@
warning: unexpected `cfg` condition value
warning: unexpected `cfg` condition value: `linuz`
--> $DIR/values-target-json.rs:13:7
|
LL | #[cfg(target_os = "linuz")]

View File

@ -1,4 +1,4 @@
warning: unexpected `cfg` condition name
warning: unexpected `cfg` condition name: `target_oz`
--> $DIR/well-known-names.rs:6:7
|
LL | #[cfg(target_oz = "linux")]
@ -8,7 +8,7 @@ LL | #[cfg(target_oz = "linux")]
|
= note: `#[warn(unexpected_cfgs)]` on by default
warning: unexpected `cfg` condition name
warning: unexpected `cfg` condition name: `features`
--> $DIR/well-known-names.rs:13:7
|
LL | #[cfg(features = "foo")]
@ -16,7 +16,7 @@ LL | #[cfg(features = "foo")]
| |
| help: there is a config with a similar name: `feature`
warning: unexpected `cfg` condition name
warning: unexpected `cfg` condition name: `uniw`
--> $DIR/well-known-names.rs:20:7
|
LL | #[cfg(uniw)]

View File

@ -1,4 +1,4 @@
warning: unexpected `cfg` condition value
warning: unexpected `cfg` condition value: `linuz`
--> $DIR/well-known-values.rs:7:7
|
LL | #[cfg(target_os = "linuz")]
@ -9,7 +9,7 @@ LL | #[cfg(target_os = "linuz")]
= note: expected values for `target_os` are: `aix`, `android`, `cuda`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `openbsd`, `psp`, `redox`, `solaris`, `solid_asp3`, `teeos`, `tvos`, `uefi`, `unknown`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`
= note: `#[warn(unexpected_cfgs)]` on by default
warning: unexpected `cfg` condition value
warning: unexpected `cfg` condition value: `0`
--> $DIR/well-known-values.rs:14:7
|
LL | #[cfg(target_has_atomic = "0")]
@ -19,7 +19,7 @@ LL | #[cfg(target_has_atomic = "0")]
|
= note: expected values for `target_has_atomic` are: (none), `128`, `16`, `32`, `64`, `8`, `ptr`
warning: unexpected `cfg` condition value
warning: unexpected `cfg` condition value: `aa`
--> $DIR/well-known-values.rs:21:7
|
LL | #[cfg(unix = "aa")]
@ -29,7 +29,7 @@ LL | #[cfg(unix = "aa")]
|
= note: no expected value for `unix`
warning: unexpected `cfg` condition value
warning: unexpected `cfg` condition value: `miri`
--> $DIR/well-known-values.rs:28:7
|
LL | #[cfg(miri = "miri")]
@ -39,7 +39,7 @@ LL | #[cfg(miri = "miri")]
|
= note: no expected value for `miri`
warning: unexpected `cfg` condition value
warning: unexpected `cfg` condition value: `linux`
--> $DIR/well-known-values.rs:35:7
|
LL | #[cfg(doc = "linux")]