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. |
|
my review was already +1, you need another community +1 (maybe consider reviewing 1-2 PRs 😉). I think @NicDevTV code review from above still needs an answer, afterwards he likely also will +1.
|
577a51d to
f4e4d43
Compare
Thanks, you're right. I addressed the indirect-borrow case by making automatic suggestions conservative: if the predicate references any local other than the predicate binding, no machine-applicable suggestion is emitted. This catches aliases such as I also added regression coverage for the Please take another look. @NicDevTV @CommanderStorm |
|
r? @Manishearth rustbot has assigned @Manishearth for the project review. Use Why was this reviewer chosen?The reviewer was selected based on:
|
f4e4d43 to
7712018
Compare
|
Are you using an LLM here? https://github.com/rust-lang/rust-clippy/blob/master/CONTRIBUTING.md#llm-policy |
I use CodeX to refine unit tests and perform a review with it before the final submission. Does this need to be mentioned in the PR detail? |
|
Please actually read and follow the LLM policy |
|
Currently we do not allow LLM generated content in rust-lang/rust-clippy. I believe I must close this PR, sorry. |
The vast majority of the content was not generated by an LLM; I primarily used the tool to review my own work. I have read the relevant information and understand your decision to close the matter, though I feel the current regulations are overly strict I will be more careful with future submissions and handle them all manually. Thank you again for your guidance throughout our extensive exchange of over thirty messages. |
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.