1
Fork 0

check-cfg: only print the list of expected names once

This commit is contained in:
Urgau 2023-10-12 17:01:55 +02:00
parent dcfc484b09
commit 001a65c4b0
3 changed files with 6 additions and 25 deletions

View file

@ -659,6 +659,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
msg: impl Into<SubdiagnosticMessage>, msg: impl Into<SubdiagnosticMessage>,
) -> &mut Self); ) -> &mut Self);
forward!(pub fn help(&mut self, msg: impl Into<SubdiagnosticMessage>) -> &mut Self); forward!(pub fn help(&mut self, msg: impl Into<SubdiagnosticMessage>) -> &mut Self);
forward!(pub fn help_once(&mut self, msg: impl Into<SubdiagnosticMessage>) -> &mut Self);
forward!(pub fn span_help( forward!(pub fn span_help(
&mut self, &mut self,
sp: impl Into<MultiSpan>, sp: impl Into<MultiSpan>,

View file

@ -758,7 +758,11 @@ pub trait LintContext: Sized {
possibilities.sort(); possibilities.sort();
let possibilities = possibilities.join("`, `"); let possibilities = possibilities.join("`, `");
db.help(format!("expected names are: `{possibilities}`")); // The list of expected names can be long (even by default) and
// so the diagnostic produced can take a lot of space. To avoid
// cloging the user output we only want to print that diagnostic
// once.
db.help_once(format!("expected names are: `{possibilities}`"));
} }
}, },
BuiltinLintDiagnostics::UnexpectedCfgValue((name, name_span), value) => { BuiltinLintDiagnostics::UnexpectedCfgValue((name, name_span), value) => {

View file

@ -73,24 +73,18 @@ warning: unexpected `cfg` condition name: `xxx`
| |
LL | cfg!(xxx = "foo"); 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: `xxx` warning: unexpected `cfg` condition name: `xxx`
--> $DIR/mix.rs:48:10 --> $DIR/mix.rs:48:10
| |
LL | cfg!(xxx); 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: `xxx` warning: unexpected `cfg` condition name: `xxx`
--> $DIR/mix.rs:50:14 --> $DIR/mix.rs:50:14
| |
LL | cfg!(any(xxx, windows)); 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: `bad` warning: unexpected `cfg` condition value: `bad`
--> $DIR/mix.rs:52:14 --> $DIR/mix.rs:52:14
@ -105,48 +99,36 @@ warning: unexpected `cfg` condition name: `xxx`
| |
LL | cfg!(any(windows, xxx)); 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: `xxx` warning: unexpected `cfg` condition name: `xxx`
--> $DIR/mix.rs:56:20 --> $DIR/mix.rs:56:20
| |
LL | cfg!(all(unix, xxx)); 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: `aa` warning: unexpected `cfg` condition name: `aa`
--> $DIR/mix.rs:58:14 --> $DIR/mix.rs:58:14
| |
LL | cfg!(all(aa, bb)); 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: `bb` warning: unexpected `cfg` condition name: `bb`
--> $DIR/mix.rs:58:18 --> $DIR/mix.rs:58:18
| |
LL | cfg!(all(aa, bb)); 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: `aa` warning: unexpected `cfg` condition name: `aa`
--> $DIR/mix.rs:61:14 --> $DIR/mix.rs:61:14
| |
LL | cfg!(any(aa, bb)); 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: `bb` warning: unexpected `cfg` condition name: `bb`
--> $DIR/mix.rs:61:18 --> $DIR/mix.rs:61:18
| |
LL | cfg!(any(aa, bb)); 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: `zebra` warning: unexpected `cfg` condition value: `zebra`
--> $DIR/mix.rs:64:20 --> $DIR/mix.rs:64:20
@ -161,8 +143,6 @@ warning: unexpected `cfg` condition name: `xxx`
| |
LL | cfg!(any(xxx, feature = "zebra")); 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: `zebra` warning: unexpected `cfg` condition value: `zebra`
--> $DIR/mix.rs:66:19 --> $DIR/mix.rs:66:19
@ -177,16 +157,12 @@ warning: unexpected `cfg` condition name: `xxx`
| |
LL | cfg!(any(xxx, unix, xxx)); 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: `xxx` warning: unexpected `cfg` condition name: `xxx`
--> $DIR/mix.rs:69:25 --> $DIR/mix.rs:69:25
| |
LL | cfg!(any(xxx, unix, xxx)); 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: `zebra` warning: unexpected `cfg` condition value: `zebra`
--> $DIR/mix.rs:72:14 --> $DIR/mix.rs:72:14