Lint against empty cfg(any()/all())#158136
Conversation
|
Some changes occurred in compiler/rustc_attr_parsing |
|
r? @Kivooeo rustbot has assigned @Kivooeo. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
55a90d0 to
9cc7a12
Compare
|
cc @rust-lang/miri |
|
Does this lint fire if the cfg predicate is produced in a macro expansion? I can see some valid use cases for producing |
No; if list.is_empty() && !list.span.from_expansion() {gates the emission. |
This comment has been minimized.
This comment has been minimized.
9cc7a12 to
a32f57f
Compare
|
cc @rust-lang/clippy |
|
This does overlap somewhat with |
| list.span, | ||
| ), | ||
| Some(sym::any) => { | ||
| if list.is_empty() && !list.span.from_expansion() { |
There was a problem hiding this comment.
Could you add a test that checks that this lint when the attribute is produced by a macro expansion?
| @@ -0,0 +1,18 @@ | |||
| //@ revisions: novers lowvers highvers | |||
| //@[lowvers] compile-flags: -Zlint-rust-version=1.87.0 | |||
There was a problem hiding this comment.
As you noted in the PR description, this PR needs to be rebased
| @eval_always = true | ||
| } | ||
|
|
||
| declare_lint! { |
There was a problem hiding this comment.
In rust-lang/rfcs#3695, this lint is mentioned as a "future possibility".
I'm not super familiar with the process, but I think this means that the change has not actually been FCP'ed yet by the lang team. Is this correct? If so, please lang-nominate this
|
Reminder, once the PR becomes ready for a review, use |
Detect usages of
cfg(any())andcfg(all())and suggest the literal boolean equivalents. When--lint-rust-versionis available, gate the diagnostic appropriately.Will need to be updated for #158134
Implements the lint suggested in rust-lang/rfcs#3695 (Tracking: #131204)
Tracking issue: #157574