Skip to content

Conversation

@lapla-cogito
Copy link
Contributor

@lapla-cogito lapla-cogito commented Dec 31, 2024

close #13781

The slow_vector_initialization lint currently only suggests using the vec! macro with size, but it does not suggest removing the resize method call.

changelog: [slow_vector_initialization]: improve slow_vector_initialization suggestion

@rustbot
Copy link
Collaborator

rustbot commented Dec 31, 2024

r? @blyxyas

rustbot has assigned @blyxyas.
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

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Dec 31, 2024
@lapla-cogito lapla-cogito force-pushed the better_suggestion_slowvecinit branch from ae1347a to dc28caa Compare December 31, 2024 07:01
@lapla-cogito lapla-cogito force-pushed the better_suggestion_slowvecinit branch from dc28caa to 4899333 Compare December 31, 2024 07:07
Copy link
Member

@blyxyas blyxyas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks! ❤️

@blyxyas blyxyas added this pull request to the merge queue Jan 1, 2025
Merged via the queue into rust-lang:master with commit 034f3d2 Jan 1, 2025
9 checks passed
github-merge-queue bot pushed a commit that referenced this pull request Jan 13, 2025
changelog: [`slow_vector_initialization`]: auto-fix when appropriate

I made a change for `slow_vector_initialization` lint suggestion to use
`vec!` with size and remove the unneeded `resize` (or similar one) call
in #13912, while only the former one was suggested in the previous
implementation. Now, I think this lint can be automatically fixed with
no unnecessary code in some cases. I wrote “in some cases” because if
there are comments between vector declaration and `resize`, Clippy
shouldn't apply auto-fix because the comment may informational.
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.

slow_vector_initialization should recommend removing Vec::resize() calls in addition to adding the size to the macro

3 participants