-
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
Identify more cases of useless into_iter()
calls
#10020
Conversation
r? @flip1995 (rustbot has picked a reviewer for you, use r? to override) |
013fb42
to
136c7a4
Compare
136c7a4
to
77ffe14
Compare
Hey @samueltardieu, would you mind adding more details to the changelog entry? Some information which cases are detected now would be helpful :) |
Done, in the style of published clippy changelog entries. |
Perfect, thank you very much! |
I'll also add this to my reviewing queue. You should have a review by the end of the week :) r? @xFrednet |
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.
Two small nits in the tests. The implementation looks good to me :)
If the type of the result of a call to `IntoIterator::into_iter()` and the type of the receiver are the same, then the receiver implements `Iterator` and `into_iter()` is the identity function. The call to `into_iter()` may be removed in all but two cases: - If the receiver implements `Copy`, `into_iter()` will produce a copy of the receiver and cannot be removed. For example, `x.into_iter().next()` will not advance `x` while `x.next()` will. - If the receiver is an immutable local variable and the call to `into_iter()` appears in a larger expression, removing the call to `into_iter()` might cause mutability issues. For example, if `x` is an immutable local variable, `x.into_iter().next()` will compile while `x.next()` will not as `next()` receives `&mut self`.
77ffe14
to
af39a8a
Compare
Everything looks good to me, thank you for the contribution and your patience! @bors r+ |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
Summary: In Rust 1.68.0, the `useless_conversion` clippy lint [got smarter](rust-lang/rust-clippy#10020). Fix all instances of that lint in Mononoke. Reviewed By: markbt Differential Revision: D44378069 fbshipit-source-id: acfd6c77c6a400830c378b4040661323e7232441
changelog: Sugg: [
useless_conversion
]: Now suggests removing calls tointo_iter()
on an expression implementingIterator
#10020