-
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
Fix needless_collect
's tendency to suggest code requiring multiple mutable borrows of the same value.
#7982
Conversation
Still needs to generalize to other mixes of let bindings, `map` method calls, etc.
…table borrows. Also add some more tests to check that it's working.
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @llogiq (or someone else) soon. Please see the contribution instructions for more information. |
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.
This is already looking quite good. I only have some minor readability nits.
1. Make the lifetime contained in LateContext `'tcx`. 2. Fix `'txc` to `'tcx` because it was a typo. 3. Refactor `IterFunctionVisitor`'s `visit_block` method to be more readable. 4. Replace uses of `rustc_middle::ty::TyKind` with `rustc::middle::ty`, and remove the `#[allow(...)]`. (Thank you llogiq for all these suggestions!)
I have fixed the suggestions. Thank you for making them! |
Thank you! @bors r+ |
📌 Commit c52b389 has been approved by |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
Fixes error specified in #7975.
changelog: [
needless_collect
] no longer suggests removal ofcollect
when removal would create code requiring mutably borrowing a value multiple times.