Skip to content

Conversation

lapla-cogito
Copy link
Contributor

@lapla-cogito lapla-cogito commented Jan 5, 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.

@rustbot
Copy link
Collaborator

rustbot commented Jan 5, 2025

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 Jan 5, 2025
Comment on lines +211 to +216
// If there is no comment in `span_to_replace`, Clippy can automatically fix the code.
let app = if span_contains_comment(cx.tcx.sess.source_map(), span_to_replace) {
Applicability::Unspecified
} else {
Applicability::MachineApplicable
};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the span to be linted contains comments, use Applicability::Unspecified, otherwise use Applicability::MachineApplicable.

@lapla-cogito
Copy link
Contributor Author

changelog CI passed

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 13, 2025
Merged via the queue into rust-lang:master with commit dcbe3ad Jan 13, 2025
11 checks passed
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.

3 participants