manual_pop_if: avoid invalid automatic suggestions - #17561
Conversation
|
Thanks for the pull request. A reviewer will take a look after it receives 2 community reviews. In the meantime, we would highly appreciate if you could try to review any of PRs waiting on community reviews. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
dd2bc7a to
92276c9
Compare
This comment has been minimized.
This comment has been minimized.
92276c9 to
9731f93
Compare
This comment has been minimized.
This comment has been minimized.
|
@CommanderStorm Thanks for the detailed feedback. I addressed the comments as follows:
I also rebased onto the latest upstream master and resolved the merge conflict. Please review it again. |
This comment has been minimized.
This comment has been minimized.
03ce274 to
577a51d
Compare
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
Resolved the merge conflicts. @CommanderStorm Please review it again. |
View all comments
changelog: [
manual_pop_if]: avoid invalid automatic suggestions when the predicate borrows the collectionmanual_pop_ifcould emit a machine-applicable suggestion when the predicate also referenced the collection being popped from.For example, rewriting:
to
vec.pop_if(...)requires a mutable borrow ofvecwhile the predicate closure also immutably borrows it, causing E0502.Only provide an automatic suggestion when the collection is a simple local path and the predicate does not reference that local. Continue emitting the lint with a help message for captured or non-local collection expressions.
Also retain the parameter pattern and avoid automatic rewrites for non-default binding modes such as
refandmut, since the predicate parameter changes from&Tto&mut T.Add UI coverage for all supported condition forms, complex collection expressions, and non-default parameter bindings.