-
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
Fixed FP in redundant_closure_call
when closures are passed to macros
#12082
Conversation
r? @dswij (rustbot has picked a reviewer for you, use r? to override) |
redundant_closure_call
when closures are passed to macrosredundant_closure_call
when closures are passed to macros
$closure(1) | ||
}; | ||
} | ||
m!(|x| println!("{x}")); |
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.
Can we also have a test case for || ()
cases as in https://github.com/rust-lang/rust-clippy/pull/12082/files#diff-ba9477a2653088e57270e74982b211e736a8f70a75f320dcba6a3d6ee37f3f75R179
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.
Something different to these?
rust-clippy/tests/ui/redundant_closure_call_fixable.rs
Lines 16 to 27 in 6558956
let a = (|| 42)(); | |
let b = (async || { | |
let x = something().await; | |
let y = something_else().await; | |
x * y | |
})(); | |
let c = (|| { | |
let x = 21; | |
let y = 2; | |
x * y | |
})(); | |
let d = (async || something().await)(); |
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.
Oh I missed that :D
There are cases where the closure call is needed in some macros, this in particular occurs when the closure has parameters. To handle this case, we allow the lint when there are no parameters in the closure, or the closure is outside a macro invocation. fixes: #11274, #1553 changelog: FP: [`redundant_closure_call`] when closures with parameters are passed in macros.
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.
LGTM, Thank you!
@bors r+ |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
There are cases where the closure call is needed in some macros, this in particular occurs when the closure has parameters. To handle this case, we allow the lint when there are no parameters in the closure, or the closure is outside a macro invocation.
fixes: #11274 #1553
changelog: FP: [
redundant_closure_call
] when closures with parameters are passed in macros.