-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
empty_enum_variants_with_brackets
: Do not lint reachable enums and enum variants used as functions in the same crate
#12971
base: master
Are you sure you want to change the base?
Conversation
faeed5b
to
895e669
Compare
@y21 Do you want to take over the review, since you already seems to be in the domain? Otherwise, I'm happy to take it. Assuming that @ARandomDev99 didn't have a specific reason to r? me in the description. |
5495546
to
ca3e9bf
Compare
I'm having trouble emitting a multipart suggestion that removes the parentheses only. |
You can make that
|
5aa0947
to
cf507a9
Compare
I just ran |
Sorry, completely missed the notification here. Does it repro if you rebase onto master? There have been a bunch of changes to uitest since then |
13d2d8c
to
2916ed9
Compare
e46009d
to
7cc588c
Compare
I just looked at the lintcheck CI results and looks like there's a fair amount of false positives: https://github.com/rust-lang/rust-clippy/actions/runs/10405234866
I think this might be because we're inserting new |
36321e5
to
9987594
Compare
I fail to understand why false positives like this show up. There's even passing tests for exactly this situation. |
}) => { | ||
redundant_use_sites.push(parentheses_span); | ||
}, | ||
None if has_no_fields(cx, None, parentheses_span) => { |
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.
Why pass None
here instead of the variant?
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.
Also, the span that's passed here is the wrong one. It expects the parentheses at the variant definition site, but this is passing the parentheses of the function call.
It doesn't explain the false positives, but passing this span makes has_no_fields
check for the wrong thing (since it uses the span for checking for #[cfg]
s).
TBH, I'd just get rid of the empty_parentheses
function entirely and use !span_contains_cfg()
instead.
The false positives seem to happen when the constructor call comes from a derive macro like #[derive(Clone)]
enum Foo {
Variant(i32)
} Thinking more about it, it might actually be better and easier to have a new |
a33082c
to
f08507f
Compare
In addition to the changes you suggested, ensuring that expressions from macro expansions aren't included in |
f08507f
to
88d6a66
Compare
Fixes #12551
changelog: [
empty_enum_variants_with_brackets
]: Do not lint reachable enums or enums which are used as functions within the same crate.r? @xFrednet