-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve check-cfg expected names diagnostic #136016
Conversation
This is not specific to the one test, it applies to nearly all the tests in the check-cfg directory. |
Many of the other tests have custom (non-builtin) check-cfgs which are reflected in the output. I can take a look at trimming those that never uses it but it will never be zero tests. |
Right. this is why i suggested trimming builtin cfgs in the diagnostics, not during normalization, because they are noisy and i don't think they're actually very helpful. |
Oh, you mean only trimming the builtins but still showing the custom ones (if there any)? I though you meant removing the entire line. I kind of like this idea, and if the users wants to see the builtins, aka well known, they can see the full list on the rustc book. |
allow-same-level
test| | ||
LL | #[cfg(tokio_unstable)] | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
= help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `feature`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `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`, `ub_checks`, `unix`, and `windows` | ||
= help: expected names are: `docsrs`, `feature`, and `test` and 30 more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this PR, Cargo users would now only see those 3 cfgs (which are Cargo defined) instead of the long list.
LL | #[cfg(list_all_well_known_cfgs)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= help: expected names are: `clippy` | ||
`debug_assertions` | ||
`doc` | ||
`doctest` | ||
`fmt_debug` | ||
`miri` | ||
`overflow_checks` | ||
`panic` | ||
`proc_macro` | ||
`relocation_model` | ||
`rustfmt` | ||
`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` | ||
`ub_checks` | ||
`unix`, and `windows` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For anti-regression and explicit-ness purpose I kept one place with the full list and applied the same trick as in #133710 to reduce merge conflicts.
@@ -14,7 +14,7 @@ warning: unexpected `cfg` condition name: `r#false` | |||
LL | #[cfg(r#false)] | |||
| ^^^^^^^ | |||
| | |||
= help: expected names are: `r#async`, `clippy`, `debug_assertions`, `doc`, `doctest`, `edition2015`, `edition2021`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `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`, `r#true`, `ub_checks`, `unix`, and `windows` | |||
= help: expected names are: `r#async`, `edition2015`, `edition2021`, and `r#true` and 30 more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This double and ... and 30 more
is unfortunate (and pre-existing). DiagSymbolList
doesn't gives us enough control to says that the list has been truncated by X amount, and even if it did, icu_list
doesn't seems to have a way to say that the list has been truncated either.
We could hack it around in check-cfg by adding a fake "X more" in the list. Idk if it's worth it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is totally fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I think this should indeed help with merge conflicts quite a lot.
@@ -14,7 +14,7 @@ warning: unexpected `cfg` condition name: `r#false` | |||
LL | #[cfg(r#false)] | |||
| ^^^^^^^ | |||
| | |||
= help: expected names are: `r#async`, `clippy`, `debug_assertions`, `doc`, `doctest`, `edition2015`, `edition2021`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `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`, `r#true`, `ub_checks`, `unix`, and `windows` | |||
= help: expected names are: `r#async`, `edition2015`, `edition2021`, and `r#true` and 30 more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is totally fine
@bors r+ rollup |
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#134300 (remove long-deprecated no-op attributes no_start and crate_id) - rust-lang#134373 (Improve and expand documentation of pipes) - rust-lang#135934 (Include missing item in the 1.81 release notes) - rust-lang#136005 (ports last few library files to new intrinsic style) - rust-lang#136016 (Improve check-cfg expected names diagnostic) - rust-lang#136039 (docs: fix typo in std::pin overview) - rust-lang#136056 (Fix typo in const stability error message) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#136016 - Urgau:check-cfg-allow-test-improv, r=jieyouxu Improve check-cfg expected names diagnostic This PR improves the check-cfg `allow-same-level` test by ~~normalizing it's output and by~~ adding more context to the test. It also filters the well known cfgs from the `expected names are` note, as to reduce the size of the diagnostic. Users can still find the full list on the [rustc book](https://doc.rust-lang.org/nightly/rustc/check-cfg.html#well-known-names-and-values), which is reinforced for Cargo users by adding a note in the Cargo check-cfg specific section. Fixes rust-lang#135995 r? `@jieyouxu`
This PR improves the check-cfg
allow-same-level
test bynormalizing it's output and byadding more context to the test.It also filters the well known cfgs from the
expected names are
note, as to reduce the size of the diagnostic. Users can still find the full list on the rustc book, which is reinforced for Cargo users by adding a note in the Cargo check-cfg specific section.Fixes #135995
r? @jieyouxu