Skip to content

Lint unnecessary vec.extend(slice.to_vec())#16738

Open
borngraced wants to merge 1 commit intorust-lang:masterfrom
borngraced:lint-extend-with-to-owned
Open

Lint unnecessary vec.extend(slice.to_vec())#16738
borngraced wants to merge 1 commit intorust-lang:masterfrom
borngraced:lint-extend-with-to-owned

Conversation

@borngraced
Copy link
Copy Markdown
Contributor

@borngraced borngraced commented Mar 20, 2026

Adds a check under unnecessary_to_owned that catches vec.extend(slice.to_vec()),
vec.extend(slice.to_owned()), and vec.extend(vec_ref.clone()) where the argument is a
needless heap allocation and suggests vec.extend_from_slice(...) instead...closes #16725

changelog: [unnecessary_to_owned]: lint unnecessary vec.extend(slice.to_vec())

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Mar 20, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 20, 2026

r? @dswij

rustbot has assigned @dswij.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: 7 candidates
  • 7 candidates expanded to 7 candidates
  • Random selection from Jarcho, dswij, llogiq, samueltardieu

@github-actions
Copy link
Copy Markdown

Lintcheck changes for 072fa0c

Lint Added Removed Changed
clippy::unnecessary_to_owned 1 0 0

This comment will be updated if you push new changes

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.

Prefer Vec::extend_from_slice over Vec::extend with slice::to_vec

3 participants