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

Identify more cases of useless into_iter() calls #10020

Merged
merged 1 commit into from
Dec 18, 2022

Conversation

samueltardieu
Copy link
Contributor

@samueltardieu samueltardieu commented Dec 1, 2022

changelog: Sugg: [useless_conversion]: Now suggests removing calls to into_iter() on an expression implementing Iterator
#10020

@rustbot
Copy link
Collaborator

rustbot commented Dec 1, 2022

r? @flip1995

(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 Dec 1, 2022
@samueltardieu samueltardieu force-pushed the more-into-iter-removal branch from 013fb42 to 136c7a4 Compare December 1, 2022 19:28
@samueltardieu samueltardieu force-pushed the more-into-iter-removal branch from 136c7a4 to 77ffe14 Compare December 2, 2022 15:17
@xFrednet
Copy link
Member

Hey @samueltardieu, would you mind adding more details to the changelog entry? Some information which cases are detected now would be helpful :)

@samueltardieu
Copy link
Contributor Author

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.

@xFrednet
Copy link
Member

Perfect, thank you very much!

@xFrednet
Copy link
Member

I'll also add this to my reviewing queue. You should have a review by the end of the week :)

r? @xFrednet

@rustbot rustbot assigned xFrednet and unassigned flip1995 Dec 14, 2022
Copy link
Member

@xFrednet xFrednet left a 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`.
@xFrednet
Copy link
Member

Everything looks good to me, thank you for the contribution and your patience!

@bors r+

@bors
Copy link
Contributor

bors commented Dec 18, 2022

📌 Commit af39a8a has been approved by xFrednet

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Dec 18, 2022

⌛ Testing commit af39a8a with merge 910a97d...

@bors
Copy link
Contributor

bors commented Dec 18, 2022

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: xFrednet
Pushing 910a97d to master...

@bors bors merged commit 910a97d into rust-lang:master Dec 18, 2022
@samueltardieu samueltardieu deleted the more-into-iter-removal branch March 5, 2023 19:19
facebook-github-bot pushed a commit to facebook/sapling that referenced this pull request Mar 24, 2023
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
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.

5 participants