Skip to content

Conversation

Icxolu
Copy link
Contributor

@Icxolu Icxolu commented May 14, 2023

Updates needless_collect to also lint collect calls in method/function arguments that take an IntoIterator (for example Extend::extend). Every Iterator trivially implements IntoIterator and collecting it only causes an unnecessary allocation.


changelog: Enhancement: [needless_collect]: Now also detects function arguments, taking a generic IntoIterator
#10777

fixes #10762

Updates `needless_collect` to lint for collecting into a method or
function argument thats taking an `IntoIterator` (for example `extend`).
Every `Iterator` trivially implements `IntoIterator` and colleting it
only causes an unnecessary allocation.
@rustbot
Copy link
Collaborator

rustbot commented May 14, 2023

r? @xFrednet

(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 May 14, 2023
@xFrednet
Copy link
Contributor

This looks good to me, thank you for the update :)

@bors r+

@bors
Copy link
Contributor

bors commented May 19, 2023

📌 Commit 84f89f3 has been approved by xFrednet

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented May 19, 2023

⌛ Testing commit 84f89f3 with merge 2a1dbba...

@bors
Copy link
Contributor

bors commented May 19, 2023

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

@bors bors merged commit 2a1dbba into rust-lang:master May 19, 2023
@Icxolu Icxolu deleted the unnecessary_collect branch May 19, 2023 13:42
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.

Use .extend(some_iter) over .extend(some_iter.collect())
4 participants