Skip to content
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

Merged
merged 1 commit into from
Jan 27, 2024
Merged

Conversation

m-rph
Copy link
Contributor

@m-rph m-rph commented Jan 3, 2024

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.

@rustbot
Copy link
Collaborator

rustbot commented Jan 3, 2024

r? @dswij

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jan 3, 2024
@m-rph m-rph changed the title Fixes FP in redundant_closure_call when closures are passed to macros Fixed FP in redundant_closure_call when closures are passed to macros Jan 3, 2024
clippy_lints/src/redundant_closure_call.rs Outdated Show resolved Hide resolved
$closure(1)
};
}
m!(|x| println!("{x}"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

@m-rph m-rph Jan 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something different to these?

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)();

Copy link
Member

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.
Copy link
Member

@dswij dswij left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Thank you!

@dswij
Copy link
Member

dswij commented Jan 27, 2024

@bors r+

@bors
Copy link
Contributor

bors commented Jan 27, 2024

📌 Commit e0228ee has been approved by dswij

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Jan 27, 2024

⌛ Testing commit e0228ee with merge 8905f78...

@bors
Copy link
Contributor

bors commented Jan 27, 2024

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: dswij
Pushing 8905f78 to master...

@bors bors merged commit 8905f78 into rust-lang:master Jan 27, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

redundant_closure_call triggered when closure is a macro parameter
4 participants