From 5345a166fe13552dc3da7fc91363457cc8ccd278 Mon Sep 17 00:00:00 2001 From: Urgau Date: Wed, 22 Nov 2023 16:50:24 +0100 Subject: [PATCH] Add more suggestion to unexpected cfg names and values --- compiler/rustc_lint/src/context.rs | 51 ++++++++++++- tests/rustdoc-ui/check-cfg/check-cfg.stderr | 2 + .../rustdoc-ui/doctest/check-cfg-test.stderr | 2 + tests/ui/check-cfg/allow-same-level.stderr | 2 + tests/ui/check-cfg/cargo-feature.none.stderr | 31 ++++++++ tests/ui/check-cfg/cargo-feature.rs | 17 ++++- tests/ui/check-cfg/cargo-feature.some.stderr | 35 +++++++++ tests/ui/check-cfg/cargo-feature.stderr | 11 --- tests/ui/check-cfg/compact-names.stderr | 2 + tests/ui/check-cfg/compact-values.stderr | 2 + tests/ui/check-cfg/concat-values.stderr | 4 + tests/ui/check-cfg/diagnotics.cargo.stderr | 71 ++++++++++++++++++ tests/ui/check-cfg/diagnotics.rs | 3 + tests/ui/check-cfg/diagnotics.rustc.stderr | 74 +++++++++++++++++++ tests/ui/check-cfg/diagnotics.stderr | 61 --------------- .../exhaustive-names-values.empty_cfg.stderr | 10 +++ .../exhaustive-names-values.feature.stderr | 6 ++ .../exhaustive-names-values.full.stderr | 6 ++ tests/ui/check-cfg/exhaustive-names.stderr | 2 + .../exhaustive-values.empty_cfg.stderr | 2 + .../exhaustive-values.without_names.stderr | 2 + tests/ui/check-cfg/mix.stderr | 65 ++++++++++++++++ .../check-cfg/no-expected-values.empty.stderr | 4 + .../check-cfg/no-expected-values.mixed.stderr | 4 + .../no-expected-values.simple.stderr | 4 + .../order-independant.values_after.stderr | 2 + .../order-independant.values_before.stderr | 2 + tests/ui/check-cfg/stmt-no-ice.stderr | 2 + tests/ui/check-cfg/unexpected-cfg-name.stderr | 2 + .../ui/check-cfg/unexpected-cfg-value.stderr | 4 + tests/ui/check-cfg/well-known-names.stderr | 10 +++ tests/ui/check-cfg/well-known-values.stderr | 50 +++++++++++++ 32 files changed, 468 insertions(+), 77 deletions(-) create mode 100644 tests/ui/check-cfg/cargo-feature.none.stderr create mode 100644 tests/ui/check-cfg/cargo-feature.some.stderr delete mode 100644 tests/ui/check-cfg/cargo-feature.stderr create mode 100644 tests/ui/check-cfg/diagnotics.cargo.stderr create mode 100644 tests/ui/check-cfg/diagnotics.rustc.stderr delete mode 100644 tests/ui/check-cfg/diagnotics.stderr diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index 024e542d4afe4..0911fa70f9725 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -706,9 +706,13 @@ pub trait LintContext { }, BuiltinLintDiagnostics::UnexpectedCfgName((name, name_span), value) => { let possibilities: Vec = sess.parse_sess.check_config.expecteds.keys().copied().collect(); + let is_from_cargo = std::env::var_os("CARGO").is_some(); + let mut is_feature_cfg = name == sym::feature; + if is_feature_cfg && is_from_cargo { + db.help("consider defining some features in `Cargo.toml`"); // Suggest the most probable if we found one - if let Some(best_match) = find_best_match_for_name(&possibilities, name, None) { + } else if let Some(best_match) = find_best_match_for_name(&possibilities, name, None) { if let Some(ExpectedValues::Some(best_match_values)) = sess.parse_sess.check_config.expecteds.get(&best_match) { let mut possibilities = best_match_values.iter() @@ -741,8 +745,8 @@ pub trait LintContext { } else { db.span_suggestion(name_span, "there is a config with a similar name", best_match, Applicability::MaybeIncorrect); } - } else if name == sym::feature && std::env::var_os("CARGO").is_some() { - db.help("consider defining some features in `Cargo.toml`"); + + is_feature_cfg |= best_match == sym::feature; } else if !possibilities.is_empty() { let mut possibilities = possibilities.iter() .map(Symbol::as_str) @@ -756,6 +760,23 @@ pub trait LintContext { // once. db.help_once(format!("expected names are: `{possibilities}`")); } + + let inst = if let Some((value, _value_span)) = value { + let pre = if is_from_cargo { "\\" } else { "" }; + format!("cfg({name}, values({pre}\"{value}{pre}\"))") + } else { + format!("cfg({name})") + }; + + if is_from_cargo { + if !is_feature_cfg { + db.help(format!("consider using a Cargo feature instead or adding `println!(\"cargo:rustc-check-cfg={inst}\");` to the top of a `build.rs`")); + } + db.note("see for more information about checking conditional configuration"); + } else { + db.help(format!("to expect this configuration use `--check-cfg={inst}`")); + db.note("see for more information about checking conditional configuration"); + } }, BuiltinLintDiagnostics::UnexpectedCfgValue((name, name_span), value) => { let Some(ExpectedValues::Some(values)) = &sess.parse_sess.check_config.expecteds.get(&name) else { @@ -767,6 +788,7 @@ pub trait LintContext { .copied() .flatten() .collect(); + let is_from_cargo = std::env::var_os("CARGO").is_some(); // Show the full list if all possible values for a given name, but don't do it // for names as the possibilities could be very long @@ -787,6 +809,8 @@ pub trait LintContext { db.span_suggestion(value_span, "there is a expected value with a similar name", format!("\"{best_match}\""), Applicability::MaybeIncorrect); } + } else if name == sym::feature && is_from_cargo { + db.help(format!("consider defining `{name}` as feature in `Cargo.toml`")); } else if let &[first_possibility] = &possibilities[..] { db.span_suggestion(name_span.shrink_to_hi(), "specify a config value", format!(" = \"{first_possibility}\""), Applicability::MaybeIncorrect); } @@ -796,6 +820,27 @@ pub trait LintContext { db.span_suggestion(name_span.shrink_to_hi().to(value_span), "remove the value", "", Applicability::MaybeIncorrect); } } + + let inst = if let Some((value, _value_span)) = value { + let pre = if is_from_cargo { "\\" } else { "" }; + format!("cfg({name}, values({pre}\"{value}{pre}\"))") + } else { + format!("cfg({name})") + }; + + if is_from_cargo { + if name == sym::feature { + if let Some((value, _value_span)) = value { + db.help(format!("consider adding `{value}` as a feature in `Cargo.toml`")); + } + } else { + db.help(format!("consider using a Cargo feature instead or adding `println!(\"cargo:rustc-check-cfg={inst}\");` to the top of a `build.rs`")); + } + db.note("see for more information about checking conditional configuration"); + } else { + db.help(format!("to expect this configuration use `--check-cfg={inst}`")); + db.note("see for more information about checking conditional configuration"); + } }, BuiltinLintDiagnostics::DeprecatedWhereclauseLocation(new_span, suggestion) => { db.multipart_suggestion( diff --git a/tests/rustdoc-ui/check-cfg/check-cfg.stderr b/tests/rustdoc-ui/check-cfg/check-cfg.stderr index d010c1f7ec627..3bca5dd083466 100644 --- a/tests/rustdoc-ui/check-cfg/check-cfg.stderr +++ b/tests/rustdoc-ui/check-cfg/check-cfg.stderr @@ -4,6 +4,8 @@ warning: unexpected `cfg` condition name: `uniz` LL | #[cfg(uniz)] | ^^^^ help: there is a config with a similar name: `unix` | + = help: to expect this configuration use `--check-cfg=cfg(uniz)` + = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: 1 warning emitted diff --git a/tests/rustdoc-ui/doctest/check-cfg-test.stderr b/tests/rustdoc-ui/doctest/check-cfg-test.stderr index 0bfd569e381eb..5524f582d5605 100644 --- a/tests/rustdoc-ui/doctest/check-cfg-test.stderr +++ b/tests/rustdoc-ui/doctest/check-cfg-test.stderr @@ -5,6 +5,8 @@ LL | #[cfg(feature = "invalid")] | ^^^^^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `test` + = help: to expect this configuration use `--check-cfg=cfg(feature, values("invalid"))` + = note: see 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/allow-same-level.stderr b/tests/ui/check-cfg/allow-same-level.stderr index 652efc3f59171..7f0faa0700de0 100644 --- a/tests/ui/check-cfg/allow-same-level.stderr +++ b/tests/ui/check-cfg/allow-same-level.stderr @@ -5,6 +5,8 @@ LL | #[cfg(FALSE)] | ^^^^^ | = help: expected names are: `debug_assertions`, `doc`, `doctest`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `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` + = help: to expect this configuration use `--check-cfg=cfg(FALSE)` + = note: see 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/cargo-feature.none.stderr b/tests/ui/check-cfg/cargo-feature.none.stderr new file mode 100644 index 0000000000000..44c8f7e30728e --- /dev/null +++ b/tests/ui/check-cfg/cargo-feature.none.stderr @@ -0,0 +1,31 @@ +warning: unexpected `cfg` condition name: `feature` + --> $DIR/cargo-feature.rs:13:7 + | +LL | #[cfg(feature = "serde")] + | ^^^^^^^^^^^^^^^^^ + | + = help: consider defining some features in `Cargo.toml` + = note: see for more information about checking conditional configuration + = note: `#[warn(unexpected_cfgs)]` on by default + +warning: unexpected `cfg` condition name: `tokio_unstable` + --> $DIR/cargo-feature.rs:18:7 + | +LL | #[cfg(tokio_unstable)] + | ^^^^^^^^^^^^^^ + | + = help: expected names are: `debug_assertions`, `doc`, `doctest`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `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` + = help: consider using a Cargo feature instead or adding `println!("cargo:rustc-check-cfg=cfg(tokio_unstable)");` to the top of a `build.rs` + = note: see for more information about checking conditional configuration + +warning: unexpected `cfg` condition name: `CONFIG_NVME` + --> $DIR/cargo-feature.rs:22:7 + | +LL | #[cfg(CONFIG_NVME = "m")] + | ^^^^^^^^^^^^^^^^^ + | + = help: consider using a Cargo feature instead or adding `println!("cargo:rustc-check-cfg=cfg(CONFIG_NVME, values(\"m\"))");` to the top of a `build.rs` + = note: see for more information about checking conditional configuration + +warning: 3 warnings emitted + diff --git a/tests/ui/check-cfg/cargo-feature.rs b/tests/ui/check-cfg/cargo-feature.rs index ea48c6ea20154..fe343d0a678cd 100644 --- a/tests/ui/check-cfg/cargo-feature.rs +++ b/tests/ui/check-cfg/cargo-feature.rs @@ -3,12 +3,25 @@ // list of all the expected names // // check-pass +// revisions: some none // rustc-env:CARGO=/usr/bin/cargo // compile-flags: --check-cfg=cfg() -Z unstable-options -// error-pattern:Cargo.toml +// [some]compile-flags: --check-cfg=cfg(feature,values("bitcode")) +// [some]compile-flags: --check-cfg=cfg(CONFIG_NVME,values("y")) +// [none]error-pattern:Cargo.toml #[cfg(feature = "serde")] -//~^ WARNING unexpected `cfg` condition name +//[none]~^ WARNING unexpected `cfg` condition name +//[some]~^^ WARNING unexpected `cfg` condition value fn ser() {} +#[cfg(tokio_unstable)] +//~^ WARNING unexpected `cfg` condition name +fn tokio() {} + +#[cfg(CONFIG_NVME = "m")] +//[none]~^ WARNING unexpected `cfg` condition name +//[some]~^^ WARNING unexpected `cfg` condition value +fn tokio() {} + fn main() {} diff --git a/tests/ui/check-cfg/cargo-feature.some.stderr b/tests/ui/check-cfg/cargo-feature.some.stderr new file mode 100644 index 0000000000000..92d63d0153487 --- /dev/null +++ b/tests/ui/check-cfg/cargo-feature.some.stderr @@ -0,0 +1,35 @@ +warning: unexpected `cfg` condition value: `serde` + --> $DIR/cargo-feature.rs:13:7 + | +LL | #[cfg(feature = "serde")] + | ^^^^^^^^^^^^^^^^^ + | + = note: expected values for `feature` are: `bitcode` + = help: consider adding `serde` as a feature in `Cargo.toml` + = note: see for more information about checking conditional configuration + = note: `#[warn(unexpected_cfgs)]` on by default + +warning: unexpected `cfg` condition name: `tokio_unstable` + --> $DIR/cargo-feature.rs:18:7 + | +LL | #[cfg(tokio_unstable)] + | ^^^^^^^^^^^^^^ + | + = help: expected names are: `CONFIG_NVME`, `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `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` + = help: consider using a Cargo feature instead or adding `println!("cargo:rustc-check-cfg=cfg(tokio_unstable)");` to the top of a `build.rs` + = note: see for more information about checking conditional configuration + +warning: unexpected `cfg` condition value: `m` + --> $DIR/cargo-feature.rs:22:7 + | +LL | #[cfg(CONFIG_NVME = "m")] + | ^^^^^^^^^^^^^^--- + | | + | help: there is a expected value with a similar name: `"y"` + | + = note: expected values for `CONFIG_NVME` are: `y` + = help: consider using a Cargo feature instead or adding `println!("cargo:rustc-check-cfg=cfg(CONFIG_NVME, values(\"m\"))");` to the top of a `build.rs` + = note: see for more information about checking conditional configuration + +warning: 3 warnings emitted + diff --git a/tests/ui/check-cfg/cargo-feature.stderr b/tests/ui/check-cfg/cargo-feature.stderr deleted file mode 100644 index 619410a28f370..0000000000000 --- a/tests/ui/check-cfg/cargo-feature.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: unexpected `cfg` condition name: `feature` - --> $DIR/cargo-feature.rs:10:7 - | -LL | #[cfg(feature = "serde")] - | ^^^^^^^^^^^^^^^^^ - | - = help: consider defining some features in `Cargo.toml` - = note: `#[warn(unexpected_cfgs)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/check-cfg/compact-names.stderr b/tests/ui/check-cfg/compact-names.stderr index d3bfb9f7100f7..dfa26f5dde0eb 100644 --- a/tests/ui/check-cfg/compact-names.stderr +++ b/tests/ui/check-cfg/compact-names.stderr @@ -5,6 +5,8 @@ LL | #[cfg(target(os = "linux", architecture = "arm"))] | ^^^^^^^^^^^^^^^^^^^^ | = help: expected names are: `debug_assertions`, `doc`, `doctest`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `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` + = help: to expect this configuration use `--check-cfg=cfg(target_architecture, values("arm"))` + = note: see 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/compact-values.stderr b/tests/ui/check-cfg/compact-values.stderr index 819b789c3e53b..10276af4d8f4f 100644 --- a/tests/ui/check-cfg/compact-values.stderr +++ b/tests/ui/check-cfg/compact-values.stderr @@ -5,6 +5,8 @@ LL | #[cfg(target(os = "linux", pointer_width = "X"))] | ^^^^^^^^^^^^^^^^^^^ | = note: expected values for `target_pointer_width` are: `16`, `32`, `64` + = help: to expect this configuration use `--check-cfg=cfg(target_pointer_width, values("X"))` + = note: see 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/concat-values.stderr b/tests/ui/check-cfg/concat-values.stderr index da2bd7d6ad929..dec43f5bda3bc 100644 --- a/tests/ui/check-cfg/concat-values.stderr +++ b/tests/ui/check-cfg/concat-values.stderr @@ -5,6 +5,8 @@ LL | #[cfg(my_cfg)] | ^^^^^^ | = note: expected values for `my_cfg` are: `bar`, `foo` + = help: to expect this configuration use `--check-cfg=cfg(my_cfg)` + = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `unk` @@ -14,6 +16,8 @@ LL | #[cfg(my_cfg = "unk")] | ^^^^^^^^^^^^^^ | = note: expected values for `my_cfg` are: `bar`, `foo` + = help: to expect this configuration use `--check-cfg=cfg(my_cfg, values("unk"))` + = note: see for more information about checking conditional configuration warning: 2 warnings emitted diff --git a/tests/ui/check-cfg/diagnotics.cargo.stderr b/tests/ui/check-cfg/diagnotics.cargo.stderr new file mode 100644 index 0000000000000..05c52bf59fad6 --- /dev/null +++ b/tests/ui/check-cfg/diagnotics.cargo.stderr @@ -0,0 +1,71 @@ +warning: unexpected `cfg` condition name: `featur` + --> $DIR/diagnotics.rs:7:7 + | +LL | #[cfg(featur)] + | ^^^^^^ help: there is a config with a similar name: `feature` + | + = help: expected values for `feature` are: `foo` + = note: see for more information about checking conditional configuration + = note: `#[warn(unexpected_cfgs)]` on by default + +warning: unexpected `cfg` condition name: `featur` + --> $DIR/diagnotics.rs:11:7 + | +LL | #[cfg(featur = "foo")] + | ^^^^^^^^^^^^^^ + | + = note: see for more information about checking conditional configuration +help: there is a config with a similar name and value + | +LL | #[cfg(feature = "foo")] + | ~~~~~~~ + +warning: unexpected `cfg` condition name: `featur` + --> $DIR/diagnotics.rs:15:7 + | +LL | #[cfg(featur = "fo")] + | ^^^^^^^^^^^^^ + | + = help: expected values for `feature` are: `foo` + = note: see for more information about checking conditional configuration +help: there is a config with a similar name and different values + | +LL | #[cfg(feature = "foo")] + | ~~~~~~~~~~~~~~~ + +warning: unexpected `cfg` condition name: `no_value` + --> $DIR/diagnotics.rs:22:7 + | +LL | #[cfg(no_value)] + | ^^^^^^^^ help: there is a config with a similar name: `no_values` + | + = help: consider using a Cargo feature instead or adding `println!("cargo:rustc-check-cfg=cfg(no_value)");` to the top of a `build.rs` + = note: see for more information about checking conditional configuration + +warning: unexpected `cfg` condition name: `no_value` + --> $DIR/diagnotics.rs:26:7 + | +LL | #[cfg(no_value = "foo")] + | ^^^^^^^^^^^^^^^^ + | + = help: consider using a Cargo feature instead or adding `println!("cargo:rustc-check-cfg=cfg(no_value, values(\"foo\"))");` to the top of a `build.rs` + = note: see for more information about checking conditional configuration +help: there is a config with a similar name and no value + | +LL | #[cfg(no_values)] + | ~~~~~~~~~ + +warning: unexpected `cfg` condition value: `bar` + --> $DIR/diagnotics.rs:30:7 + | +LL | #[cfg(no_values = "bar")] + | ^^^^^^^^^-------- + | | + | help: remove the value + | + = note: no expected value for `no_values` + = help: consider using a Cargo feature instead or adding `println!("cargo:rustc-check-cfg=cfg(no_values, values(\"bar\"))");` to the top of a `build.rs` + = note: see for more information about checking conditional configuration + +warning: 6 warnings emitted + diff --git a/tests/ui/check-cfg/diagnotics.rs b/tests/ui/check-cfg/diagnotics.rs index 45875bddc1762..33073f05f6979 100644 --- a/tests/ui/check-cfg/diagnotics.rs +++ b/tests/ui/check-cfg/diagnotics.rs @@ -1,4 +1,7 @@ // check-pass +// revisions: cargo rustc +// [rustc]unset-rustc-env:CARGO +// [cargo]rustc-env:CARGO=/usr/bin/cargo // compile-flags: --check-cfg=cfg(feature,values("foo")) --check-cfg=cfg(no_values) -Z unstable-options #[cfg(featur)] diff --git a/tests/ui/check-cfg/diagnotics.rustc.stderr b/tests/ui/check-cfg/diagnotics.rustc.stderr new file mode 100644 index 0000000000000..2b1129a392006 --- /dev/null +++ b/tests/ui/check-cfg/diagnotics.rustc.stderr @@ -0,0 +1,74 @@ +warning: unexpected `cfg` condition name: `featur` + --> $DIR/diagnotics.rs:7:7 + | +LL | #[cfg(featur)] + | ^^^^^^ help: there is a config with a similar name: `feature` + | + = help: expected values for `feature` are: `foo` + = help: to expect this configuration use `--check-cfg=cfg(featur)` + = note: see for more information about checking conditional configuration + = note: `#[warn(unexpected_cfgs)]` on by default + +warning: unexpected `cfg` condition name: `featur` + --> $DIR/diagnotics.rs:11:7 + | +LL | #[cfg(featur = "foo")] + | ^^^^^^^^^^^^^^ + | + = help: to expect this configuration use `--check-cfg=cfg(featur, values("foo"))` + = note: see for more information about checking conditional configuration +help: there is a config with a similar name and value + | +LL | #[cfg(feature = "foo")] + | ~~~~~~~ + +warning: unexpected `cfg` condition name: `featur` + --> $DIR/diagnotics.rs:15:7 + | +LL | #[cfg(featur = "fo")] + | ^^^^^^^^^^^^^ + | + = help: expected values for `feature` are: `foo` + = help: to expect this configuration use `--check-cfg=cfg(featur, values("fo"))` + = note: see for more information about checking conditional configuration +help: there is a config with a similar name and different values + | +LL | #[cfg(feature = "foo")] + | ~~~~~~~~~~~~~~~ + +warning: unexpected `cfg` condition name: `no_value` + --> $DIR/diagnotics.rs:22:7 + | +LL | #[cfg(no_value)] + | ^^^^^^^^ help: there is a config with a similar name: `no_values` + | + = help: to expect this configuration use `--check-cfg=cfg(no_value)` + = note: see for more information about checking conditional configuration + +warning: unexpected `cfg` condition name: `no_value` + --> $DIR/diagnotics.rs:26:7 + | +LL | #[cfg(no_value = "foo")] + | ^^^^^^^^^^^^^^^^ + | + = help: to expect this configuration use `--check-cfg=cfg(no_value, values("foo"))` + = note: see for more information about checking conditional configuration +help: there is a config with a similar name and no value + | +LL | #[cfg(no_values)] + | ~~~~~~~~~ + +warning: unexpected `cfg` condition value: `bar` + --> $DIR/diagnotics.rs:30:7 + | +LL | #[cfg(no_values = "bar")] + | ^^^^^^^^^-------- + | | + | help: remove the value + | + = note: no expected value for `no_values` + = help: to expect this configuration use `--check-cfg=cfg(no_values, values("bar"))` + = note: see for more information about checking conditional configuration + +warning: 6 warnings emitted + diff --git a/tests/ui/check-cfg/diagnotics.stderr b/tests/ui/check-cfg/diagnotics.stderr deleted file mode 100644 index 31c0db03a7e0f..0000000000000 --- a/tests/ui/check-cfg/diagnotics.stderr +++ /dev/null @@ -1,61 +0,0 @@ -warning: unexpected `cfg` condition name: `featur` - --> $DIR/diagnotics.rs:4:7 - | -LL | #[cfg(featur)] - | ^^^^^^ help: there is a config with a similar name: `feature` - | - = help: expected values for `feature` are: `foo` - = note: `#[warn(unexpected_cfgs)]` on by default - -warning: unexpected `cfg` condition name: `featur` - --> $DIR/diagnotics.rs:8:7 - | -LL | #[cfg(featur = "foo")] - | ^^^^^^^^^^^^^^ - | -help: there is a config with a similar name and value - | -LL | #[cfg(feature = "foo")] - | ~~~~~~~ - -warning: unexpected `cfg` condition name: `featur` - --> $DIR/diagnotics.rs:12:7 - | -LL | #[cfg(featur = "fo")] - | ^^^^^^^^^^^^^ - | - = help: expected values for `feature` are: `foo` -help: there is a config with a similar name and different values - | -LL | #[cfg(feature = "foo")] - | ~~~~~~~~~~~~~~~ - -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: `no_value` - --> $DIR/diagnotics.rs:23:7 - | -LL | #[cfg(no_value = "foo")] - | ^^^^^^^^^^^^^^^^ - | -help: there is a config with a similar name and no value - | -LL | #[cfg(no_values)] - | ~~~~~~~~~ - -warning: unexpected `cfg` condition value: `bar` - --> $DIR/diagnotics.rs:27:7 - | -LL | #[cfg(no_values = "bar")] - | ^^^^^^^^^-------- - | | - | help: remove the value - | - = note: no expected value for `no_values` - -warning: 6 warnings emitted - diff --git a/tests/ui/check-cfg/exhaustive-names-values.empty_cfg.stderr b/tests/ui/check-cfg/exhaustive-names-values.empty_cfg.stderr index 9501c134bacbc..27af821202679 100644 --- a/tests/ui/check-cfg/exhaustive-names-values.empty_cfg.stderr +++ b/tests/ui/check-cfg/exhaustive-names-values.empty_cfg.stderr @@ -5,6 +5,8 @@ LL | #[cfg(unknown_key = "value")] | ^^^^^^^^^^^^^^^^^^^^^ | = help: expected names are: `debug_assertions`, `doc`, `doctest`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `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` + = help: to expect this configuration use `--check-cfg=cfg(unknown_key, values("value"))` + = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `value` @@ -16,18 +18,26 @@ LL | #[cfg(test = "value")] | help: remove the value | = note: no expected value for `test` + = help: to expect this configuration use `--check-cfg=cfg(test, values("value"))` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `feature` --> $DIR/exhaustive-names-values.rs:18:7 | LL | #[cfg(feature = "unk")] | ^^^^^^^^^^^^^^^ + | + = help: to expect this configuration use `--check-cfg=cfg(feature, values("unk"))` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `feature` --> $DIR/exhaustive-names-values.rs:25:7 | LL | #[cfg(feature = "std")] | ^^^^^^^^^^^^^^^ + | + = help: to expect this configuration use `--check-cfg=cfg(feature, values("std"))` + = note: see for more information about checking conditional configuration warning: 4 warnings emitted diff --git a/tests/ui/check-cfg/exhaustive-names-values.feature.stderr b/tests/ui/check-cfg/exhaustive-names-values.feature.stderr index ea204eaff1ba7..a5aa80ef8e537 100644 --- a/tests/ui/check-cfg/exhaustive-names-values.feature.stderr +++ b/tests/ui/check-cfg/exhaustive-names-values.feature.stderr @@ -5,6 +5,8 @@ LL | #[cfg(unknown_key = "value")] | ^^^^^^^^^^^^^^^^^^^^^ | = help: expected names are: `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `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` + = help: to expect this configuration use `--check-cfg=cfg(unknown_key, values("value"))` + = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `value` @@ -16,6 +18,8 @@ LL | #[cfg(test = "value")] | help: remove the value | = note: no expected value for `test` + = help: to expect this configuration use `--check-cfg=cfg(test, values("value"))` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `unk` --> $DIR/exhaustive-names-values.rs:18:7 @@ -24,6 +28,8 @@ LL | #[cfg(feature = "unk")] | ^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `std` + = help: to expect this configuration use `--check-cfg=cfg(feature, values("unk"))` + = note: see for more information about checking conditional configuration warning: 3 warnings emitted diff --git a/tests/ui/check-cfg/exhaustive-names-values.full.stderr b/tests/ui/check-cfg/exhaustive-names-values.full.stderr index ea204eaff1ba7..a5aa80ef8e537 100644 --- a/tests/ui/check-cfg/exhaustive-names-values.full.stderr +++ b/tests/ui/check-cfg/exhaustive-names-values.full.stderr @@ -5,6 +5,8 @@ LL | #[cfg(unknown_key = "value")] | ^^^^^^^^^^^^^^^^^^^^^ | = help: expected names are: `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `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` + = help: to expect this configuration use `--check-cfg=cfg(unknown_key, values("value"))` + = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `value` @@ -16,6 +18,8 @@ LL | #[cfg(test = "value")] | help: remove the value | = note: no expected value for `test` + = help: to expect this configuration use `--check-cfg=cfg(test, values("value"))` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `unk` --> $DIR/exhaustive-names-values.rs:18:7 @@ -24,6 +28,8 @@ LL | #[cfg(feature = "unk")] | ^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `std` + = help: to expect this configuration use `--check-cfg=cfg(feature, values("unk"))` + = note: see for more information about checking conditional configuration warning: 3 warnings emitted diff --git a/tests/ui/check-cfg/exhaustive-names.stderr b/tests/ui/check-cfg/exhaustive-names.stderr index c5f6d537c5e98..cfac28cd9b9ba 100644 --- a/tests/ui/check-cfg/exhaustive-names.stderr +++ b/tests/ui/check-cfg/exhaustive-names.stderr @@ -5,6 +5,8 @@ LL | #[cfg(unknown_key = "value")] | ^^^^^^^^^^^^^^^^^^^^^ | = help: expected names are: `debug_assertions`, `doc`, `doctest`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `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` + = help: to expect this configuration use `--check-cfg=cfg(unknown_key, values("value"))` + = note: see 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/exhaustive-values.empty_cfg.stderr b/tests/ui/check-cfg/exhaustive-values.empty_cfg.stderr index 745646bda1c9f..0a7bd81b8aaff 100644 --- a/tests/ui/check-cfg/exhaustive-values.empty_cfg.stderr +++ b/tests/ui/check-cfg/exhaustive-values.empty_cfg.stderr @@ -7,6 +7,8 @@ LL | #[cfg(test = "value")] | help: remove the value | = note: no expected value for `test` + = help: to expect this configuration use `--check-cfg=cfg(test, values("value"))` + = note: see 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/exhaustive-values.without_names.stderr b/tests/ui/check-cfg/exhaustive-values.without_names.stderr index 745646bda1c9f..0a7bd81b8aaff 100644 --- a/tests/ui/check-cfg/exhaustive-values.without_names.stderr +++ b/tests/ui/check-cfg/exhaustive-values.without_names.stderr @@ -7,6 +7,8 @@ LL | #[cfg(test = "value")] | help: remove the value | = note: no expected value for `test` + = help: to expect this configuration use `--check-cfg=cfg(test, values("value"))` + = note: see 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.stderr b/tests/ui/check-cfg/mix.stderr index 25b8f95ae2f9b..39660a2fd6efb 100644 --- a/tests/ui/check-cfg/mix.stderr +++ b/tests/ui/check-cfg/mix.stderr @@ -4,6 +4,8 @@ warning: unexpected `cfg` condition name: `widnows` LL | #[cfg(widnows)] | ^^^^^^^ help: there is a config with a similar name: `windows` | + = help: to expect this configuration use `--check-cfg=cfg(widnows)` + = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: (none) @@ -13,6 +15,8 @@ LL | #[cfg(feature)] | ^^^^^^^- help: specify a config value: `= "foo"` | = note: expected values for `feature` are: `foo` + = help: to expect this configuration use `--check-cfg=cfg(feature)` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `bar` --> $DIR/mix.rs:23:7 @@ -21,6 +25,8 @@ LL | #[cfg(feature = "bar")] | ^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `foo` + = help: to expect this configuration use `--check-cfg=cfg(feature, values("bar"))` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `zebra` --> $DIR/mix.rs:27:7 @@ -29,6 +35,8 @@ LL | #[cfg(feature = "zebra")] | ^^^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `foo` + = help: to expect this configuration use `--check-cfg=cfg(feature, values("zebra"))` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `uu` --> $DIR/mix.rs:31:12 @@ -37,12 +45,17 @@ LL | #[cfg_attr(uu, test)] | ^^ | = help: expected names are: `debug_assertions`, `doc`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `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` + = help: to expect this configuration use `--check-cfg=cfg(uu)` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `widnows` --> $DIR/mix.rs:40:10 | LL | cfg!(widnows); | ^^^^^^^ help: there is a config with a similar name: `windows` + | + = help: to expect this configuration use `--check-cfg=cfg(widnows)` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `bar` --> $DIR/mix.rs:43:10 @@ -51,6 +64,8 @@ LL | cfg!(feature = "bar"); | ^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `foo` + = help: to expect this configuration use `--check-cfg=cfg(feature, values("bar"))` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `zebra` --> $DIR/mix.rs:45:10 @@ -59,24 +74,35 @@ LL | cfg!(feature = "zebra"); | ^^^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `foo` + = help: to expect this configuration use `--check-cfg=cfg(feature, values("zebra"))` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `xxx` --> $DIR/mix.rs:47:10 | LL | cfg!(xxx = "foo"); | ^^^^^^^^^^^ + | + = help: to expect this configuration use `--check-cfg=cfg(xxx, values("foo"))` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `xxx` --> $DIR/mix.rs:49:10 | LL | cfg!(xxx); | ^^^ + | + = help: to expect this configuration use `--check-cfg=cfg(xxx)` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `xxx` --> $DIR/mix.rs:51:14 | LL | cfg!(any(xxx, windows)); | ^^^ + | + = help: to expect this configuration use `--check-cfg=cfg(xxx)` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `bad` --> $DIR/mix.rs:53:14 @@ -85,42 +111,62 @@ LL | cfg!(any(feature = "bad", windows)); | ^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `foo` + = help: to expect this configuration use `--check-cfg=cfg(feature, values("bad"))` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `xxx` --> $DIR/mix.rs:55:23 | LL | cfg!(any(windows, xxx)); | ^^^ + | + = help: to expect this configuration use `--check-cfg=cfg(xxx)` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `xxx` --> $DIR/mix.rs:57:20 | LL | cfg!(all(unix, xxx)); | ^^^ + | + = help: to expect this configuration use `--check-cfg=cfg(xxx)` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `aa` --> $DIR/mix.rs:59:14 | LL | cfg!(all(aa, bb)); | ^^ + | + = help: to expect this configuration use `--check-cfg=cfg(aa)` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `bb` --> $DIR/mix.rs:59:18 | LL | cfg!(all(aa, bb)); | ^^ + | + = help: to expect this configuration use `--check-cfg=cfg(bb)` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `aa` --> $DIR/mix.rs:62:14 | LL | cfg!(any(aa, bb)); | ^^ + | + = help: to expect this configuration use `--check-cfg=cfg(aa)` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `bb` --> $DIR/mix.rs:62:18 | LL | cfg!(any(aa, bb)); | ^^ + | + = help: to expect this configuration use `--check-cfg=cfg(bb)` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `zebra` --> $DIR/mix.rs:65:20 @@ -129,12 +175,17 @@ LL | cfg!(any(unix, feature = "zebra")); | ^^^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `foo` + = help: to expect this configuration use `--check-cfg=cfg(feature, values("zebra"))` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `xxx` --> $DIR/mix.rs:67:14 | LL | cfg!(any(xxx, feature = "zebra")); | ^^^ + | + = help: to expect this configuration use `--check-cfg=cfg(xxx)` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `zebra` --> $DIR/mix.rs:67:19 @@ -143,18 +194,26 @@ LL | cfg!(any(xxx, feature = "zebra")); | ^^^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `foo` + = help: to expect this configuration use `--check-cfg=cfg(feature, values("zebra"))` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `xxx` --> $DIR/mix.rs:70:14 | LL | cfg!(any(xxx, unix, xxx)); | ^^^ + | + = help: to expect this configuration use `--check-cfg=cfg(xxx)` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `xxx` --> $DIR/mix.rs:70:25 | LL | cfg!(any(xxx, unix, xxx)); | ^^^ + | + = help: to expect this configuration use `--check-cfg=cfg(xxx)` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `zebra` --> $DIR/mix.rs:73:14 @@ -163,6 +222,8 @@ LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra")); | ^^^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `foo` + = help: to expect this configuration use `--check-cfg=cfg(feature, values("zebra"))` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `zebra` --> $DIR/mix.rs:73:33 @@ -171,6 +232,8 @@ LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra")); | ^^^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `foo` + = help: to expect this configuration use `--check-cfg=cfg(feature, values("zebra"))` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `zebra` --> $DIR/mix.rs:73:52 @@ -179,6 +242,8 @@ LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra")); | ^^^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `foo` + = help: to expect this configuration use `--check-cfg=cfg(feature, values("zebra"))` + = note: see for more information about checking conditional configuration warning: 26 warnings emitted diff --git a/tests/ui/check-cfg/no-expected-values.empty.stderr b/tests/ui/check-cfg/no-expected-values.empty.stderr index 0969d61dd40e9..ae55c95c0b180 100644 --- a/tests/ui/check-cfg/no-expected-values.empty.stderr +++ b/tests/ui/check-cfg/no-expected-values.empty.stderr @@ -7,6 +7,8 @@ LL | #[cfg(feature = "foo")] | help: remove the value | = note: no expected value for `feature` + = help: to expect this configuration use `--check-cfg=cfg(feature, values("foo"))` + = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `foo` @@ -18,6 +20,8 @@ LL | #[cfg(test = "foo")] | help: remove the value | = note: no expected value for `test` + = help: to expect this configuration use `--check-cfg=cfg(test, values("foo"))` + = note: see for more information about checking conditional configuration warning: 2 warnings emitted diff --git a/tests/ui/check-cfg/no-expected-values.mixed.stderr b/tests/ui/check-cfg/no-expected-values.mixed.stderr index 0969d61dd40e9..ae55c95c0b180 100644 --- a/tests/ui/check-cfg/no-expected-values.mixed.stderr +++ b/tests/ui/check-cfg/no-expected-values.mixed.stderr @@ -7,6 +7,8 @@ LL | #[cfg(feature = "foo")] | help: remove the value | = note: no expected value for `feature` + = help: to expect this configuration use `--check-cfg=cfg(feature, values("foo"))` + = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `foo` @@ -18,6 +20,8 @@ LL | #[cfg(test = "foo")] | help: remove the value | = note: no expected value for `test` + = help: to expect this configuration use `--check-cfg=cfg(test, values("foo"))` + = note: see for more information about checking conditional configuration warning: 2 warnings emitted diff --git a/tests/ui/check-cfg/no-expected-values.simple.stderr b/tests/ui/check-cfg/no-expected-values.simple.stderr index 0969d61dd40e9..ae55c95c0b180 100644 --- a/tests/ui/check-cfg/no-expected-values.simple.stderr +++ b/tests/ui/check-cfg/no-expected-values.simple.stderr @@ -7,6 +7,8 @@ LL | #[cfg(feature = "foo")] | help: remove the value | = note: no expected value for `feature` + = help: to expect this configuration use `--check-cfg=cfg(feature, values("foo"))` + = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `foo` @@ -18,6 +20,8 @@ LL | #[cfg(test = "foo")] | help: remove the value | = note: no expected value for `test` + = help: to expect this configuration use `--check-cfg=cfg(test, values("foo"))` + = note: see for more information about checking conditional configuration warning: 2 warnings emitted diff --git a/tests/ui/check-cfg/order-independant.values_after.stderr b/tests/ui/check-cfg/order-independant.values_after.stderr index ed162fb5489d4..d1de26ba30394 100644 --- a/tests/ui/check-cfg/order-independant.values_after.stderr +++ b/tests/ui/check-cfg/order-independant.values_after.stderr @@ -5,6 +5,8 @@ LL | #[cfg(a = "unk")] | ^^^^^^^^^ | = note: expected values for `a` are: (none), `b` + = help: to expect this configuration use `--check-cfg=cfg(a, values("unk"))` + = note: see 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/order-independant.values_before.stderr b/tests/ui/check-cfg/order-independant.values_before.stderr index ed162fb5489d4..d1de26ba30394 100644 --- a/tests/ui/check-cfg/order-independant.values_before.stderr +++ b/tests/ui/check-cfg/order-independant.values_before.stderr @@ -5,6 +5,8 @@ LL | #[cfg(a = "unk")] | ^^^^^^^^^ | = note: expected values for `a` are: (none), `b` + = help: to expect this configuration use `--check-cfg=cfg(a, values("unk"))` + = note: see 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/stmt-no-ice.stderr b/tests/ui/check-cfg/stmt-no-ice.stderr index c2483fe4a06fe..112367606dcbc 100644 --- a/tests/ui/check-cfg/stmt-no-ice.stderr +++ b/tests/ui/check-cfg/stmt-no-ice.stderr @@ -5,6 +5,8 @@ LL | #[cfg(crossbeam_loom)] | ^^^^^^^^^^^^^^ | = help: expected names are: `debug_assertions`, `doc`, `doctest`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `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` + = help: to expect this configuration use `--check-cfg=cfg(crossbeam_loom)` + = note: see 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/unexpected-cfg-name.stderr b/tests/ui/check-cfg/unexpected-cfg-name.stderr index 0874ccfc4617a..8748b324fb667 100644 --- a/tests/ui/check-cfg/unexpected-cfg-name.stderr +++ b/tests/ui/check-cfg/unexpected-cfg-name.stderr @@ -4,6 +4,8 @@ warning: unexpected `cfg` condition name: `widnows` LL | #[cfg(widnows)] | ^^^^^^^ help: there is a config with a similar name: `windows` | + = help: to expect this configuration use `--check-cfg=cfg(widnows)` + = note: see 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/unexpected-cfg-value.stderr b/tests/ui/check-cfg/unexpected-cfg-value.stderr index 31c473a08cb2b..e5435d376709f 100644 --- a/tests/ui/check-cfg/unexpected-cfg-value.stderr +++ b/tests/ui/check-cfg/unexpected-cfg-value.stderr @@ -7,6 +7,8 @@ LL | #[cfg(feature = "sedre")] | help: there is a expected value with a similar name: `"serde"` | = note: expected values for `feature` are: `full`, `serde` + = help: to expect this configuration use `--check-cfg=cfg(feature, values("sedre"))` + = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `rand` @@ -16,6 +18,8 @@ LL | #[cfg(feature = "rand")] | ^^^^^^^^^^^^^^^^ | = note: expected values for `feature` are: `full`, `serde` + = help: to expect this configuration use `--check-cfg=cfg(feature, values("rand"))` + = note: see for more information about checking conditional configuration warning: 2 warnings emitted diff --git a/tests/ui/check-cfg/well-known-names.stderr b/tests/ui/check-cfg/well-known-names.stderr index 6040663074da7..763ba4646c3c0 100644 --- a/tests/ui/check-cfg/well-known-names.stderr +++ b/tests/ui/check-cfg/well-known-names.stderr @@ -4,6 +4,8 @@ warning: unexpected `cfg` condition name: `target_oz` LL | #[cfg(target_oz = "linux")] | ^^^^^^^^^^^^^^^^^^^ | + = help: to expect this configuration use `--check-cfg=cfg(target_oz, values("linux"))` + = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default help: there is a config with a similar name and value | @@ -17,18 +19,26 @@ LL | #[cfg(features = "foo")] | ^^^^^^^^^^^^^^^^ | = help: expected names are: `debug_assertions`, `doc`, `doctest`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `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` + = help: to expect this configuration use `--check-cfg=cfg(features, values("foo"))` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `feature` --> $DIR/well-known-names.rs:17:7 | LL | #[cfg(feature = "foo")] | ^^^^^^^^^^^^^^^ + | + = help: to expect this configuration use `--check-cfg=cfg(feature, values("foo"))` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `uniw` --> $DIR/well-known-names.rs:21:7 | LL | #[cfg(uniw)] | ^^^^ help: there is a config with a similar name: `unix` + | + = help: to expect this configuration use `--check-cfg=cfg(uniw)` + = note: see for more information about checking conditional configuration warning: 4 warnings emitted diff --git a/tests/ui/check-cfg/well-known-values.stderr b/tests/ui/check-cfg/well-known-values.stderr index a6b9c75a142d9..1e92639fd1110 100644 --- a/tests/ui/check-cfg/well-known-values.stderr +++ b/tests/ui/check-cfg/well-known-values.stderr @@ -7,6 +7,8 @@ LL | debug_assertions = "_UNEXPECTED_VALUE", | help: remove the value | = note: no expected value for `debug_assertions` + = help: to expect this configuration use `--check-cfg=cfg(debug_assertions, values("_UNEXPECTED_VALUE"))` + = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` @@ -18,6 +20,8 @@ LL | doc = "_UNEXPECTED_VALUE", | help: remove the value | = note: no expected value for `doc` + = help: to expect this configuration use `--check-cfg=cfg(doc, values("_UNEXPECTED_VALUE"))` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:30:5 @@ -28,6 +32,8 @@ LL | doctest = "_UNEXPECTED_VALUE", | help: remove the value | = note: no expected value for `doctest` + = help: to expect this configuration use `--check-cfg=cfg(doctest, values("_UNEXPECTED_VALUE"))` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:32:5 @@ -38,6 +44,8 @@ LL | miri = "_UNEXPECTED_VALUE", | help: remove the value | = note: no expected value for `miri` + = help: to expect this configuration use `--check-cfg=cfg(miri, values("_UNEXPECTED_VALUE"))` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:34:5 @@ -48,6 +56,8 @@ LL | overflow_checks = "_UNEXPECTED_VALUE", | help: remove the value | = note: no expected value for `overflow_checks` + = help: to expect this configuration use `--check-cfg=cfg(overflow_checks, values("_UNEXPECTED_VALUE"))` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:36:5 @@ -56,6 +66,8 @@ LL | panic = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `panic` are: `abort`, `unwind` + = help: to expect this configuration use `--check-cfg=cfg(panic, values("_UNEXPECTED_VALUE"))` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:38:5 @@ -66,6 +78,8 @@ LL | proc_macro = "_UNEXPECTED_VALUE", | help: remove the value | = note: no expected value for `proc_macro` + = help: to expect this configuration use `--check-cfg=cfg(proc_macro, values("_UNEXPECTED_VALUE"))` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:40:5 @@ -74,6 +88,8 @@ LL | relocation_model = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `relocation_model` are: `dynamic-no-pic`, `pic`, `pie`, `ropi`, `ropi-rwpi`, `rwpi`, `static` + = help: to expect this configuration use `--check-cfg=cfg(relocation_model, values("_UNEXPECTED_VALUE"))` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:42:5 @@ -82,6 +98,8 @@ LL | sanitize = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `sanitize` are: `address`, `cfi`, `hwaddress`, `kcfi`, `kernel-address`, `leak`, `memory`, `memtag`, `safestack`, `shadow-call-stack`, `thread` + = help: to expect this configuration use `--check-cfg=cfg(sanitize, values("_UNEXPECTED_VALUE"))` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:44:5 @@ -90,6 +108,8 @@ LL | target_abi = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `target_abi` are: ``, `abi64`, `abiv2`, `abiv2hf`, `eabi`, `eabihf`, `elf`, `fortanix`, `ilp32`, `llvm`, `macabi`, `sim`, `softfloat`, `spe`, `uwp`, `vec-extabi`, `x32` + = help: to expect this configuration use `--check-cfg=cfg(target_abi, values("_UNEXPECTED_VALUE"))` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:46:5 @@ -98,6 +118,8 @@ LL | target_arch = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `target_arch` are: `aarch64`, `arm`, `avr`, `bpf`, `csky`, `hexagon`, `loongarch64`, `m68k`, `mips`, `mips32r6`, `mips64`, `mips64r6`, `msp430`, `nvptx64`, `powerpc`, `powerpc64`, `riscv32`, `riscv64`, `s390x`, `sparc`, `sparc64`, `wasm32`, `wasm64`, `x86`, `x86_64` + = help: to expect this configuration use `--check-cfg=cfg(target_arch, values("_UNEXPECTED_VALUE"))` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:48:5 @@ -106,6 +128,8 @@ LL | target_endian = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `target_endian` are: `big`, `little` + = help: to expect this configuration use `--check-cfg=cfg(target_endian, values("_UNEXPECTED_VALUE"))` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:50:5 @@ -114,6 +138,8 @@ LL | target_env = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `target_env` are: ``, `eabihf`, `gnu`, `gnueabihf`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `ohos`, `psx`, `relibc`, `sgx`, `uclibc` + = help: to expect this configuration use `--check-cfg=cfg(target_env, values("_UNEXPECTED_VALUE"))` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:52:5 @@ -122,6 +148,8 @@ LL | target_family = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `target_family` are: `unix`, `wasm`, `windows` + = help: to expect this configuration use `--check-cfg=cfg(target_family, values("_UNEXPECTED_VALUE"))` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:55:5 @@ -130,6 +158,8 @@ LL | target_has_atomic = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `target_has_atomic` are: (none), `128`, `16`, `32`, `64`, `8`, `ptr` + = help: to expect this configuration use `--check-cfg=cfg(target_has_atomic, values("_UNEXPECTED_VALUE"))` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:57:5 @@ -138,6 +168,8 @@ LL | target_has_atomic_equal_alignment = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `target_has_atomic_equal_alignment` are: (none), `128`, `16`, `32`, `64`, `8`, `ptr` + = help: to expect this configuration use `--check-cfg=cfg(target_has_atomic_equal_alignment, values("_UNEXPECTED_VALUE"))` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:59:5 @@ -146,6 +178,8 @@ LL | target_has_atomic_load_store = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `target_has_atomic_load_store` are: (none), `128`, `16`, `32`, `64`, `8`, `ptr` + = help: to expect this configuration use `--check-cfg=cfg(target_has_atomic_load_store, values("_UNEXPECTED_VALUE"))` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:61:5 @@ -154,6 +188,8 @@ LL | target_os = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = 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` + = help: to expect this configuration use `--check-cfg=cfg(target_os, values("_UNEXPECTED_VALUE"))` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:63:5 @@ -162,6 +198,8 @@ LL | target_pointer_width = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `target_pointer_width` are: `16`, `32`, `64` + = help: to expect this configuration use `--check-cfg=cfg(target_pointer_width, values("_UNEXPECTED_VALUE"))` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:65:5 @@ -172,6 +210,8 @@ LL | target_thread_local = "_UNEXPECTED_VALUE", | help: remove the value | = note: no expected value for `target_thread_local` + = help: to expect this configuration use `--check-cfg=cfg(target_thread_local, values("_UNEXPECTED_VALUE"))` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:67:5 @@ -180,6 +220,8 @@ LL | target_vendor = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `target_vendor` are: `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `nintendo`, `nvidia`, `pc`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `win7`, `wrs` + = help: to expect this configuration use `--check-cfg=cfg(target_vendor, values("_UNEXPECTED_VALUE"))` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:69:5 @@ -190,6 +232,8 @@ LL | test = "_UNEXPECTED_VALUE", | help: remove the value | = note: no expected value for `test` + = help: to expect this configuration use `--check-cfg=cfg(test, values("_UNEXPECTED_VALUE"))` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:71:5 @@ -200,6 +244,8 @@ LL | unix = "_UNEXPECTED_VALUE", | help: remove the value | = note: no expected value for `unix` + = help: to expect this configuration use `--check-cfg=cfg(unix, values("_UNEXPECTED_VALUE"))` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` --> $DIR/well-known-values.rs:73:5 @@ -210,6 +256,8 @@ LL | windows = "_UNEXPECTED_VALUE", | help: remove the value | = note: no expected value for `windows` + = help: to expect this configuration use `--check-cfg=cfg(windows, values("_UNEXPECTED_VALUE"))` + = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `linuz` --> $DIR/well-known-values.rs:79:7 @@ -220,6 +268,8 @@ LL | #[cfg(target_os = "linuz")] // testing that we suggest `linux` | help: there is a expected value with a similar name: `"linux"` | = 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` + = help: to expect this configuration use `--check-cfg=cfg(target_os, values("linuz"))` + = note: see for more information about checking conditional configuration warning: 25 warnings emitted