-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
New Lint: push same item to Vec (#4078) #4647
Conversation
☔ The latest upstream changes (presumably #4560) made this pull request unmergeable. Please resolve the merge conflicts. |
de7681b
to
e9f12f0
Compare
☔ The latest upstream changes (presumably #4683) made this pull request unmergeable. Please resolve the merge conflicts. |
@EthanTheMaster you have merge conflict markers in your latest commit (in README.md) |
☔ The latest upstream changes (presumably #4650) made this pull request unmergeable. Please resolve the merge conflicts. |
☔ The latest upstream changes (presumably #4788) made this pull request unmergeable. Please resolve the merge conflicts. |
☔ The latest upstream changes (presumably #4839) made this pull request unmergeable. Please resolve the merge conflicts. |
Thanks for contributing to Clippy! Sadly this PR was not updated in quite some time. If you waited on input from a reviewer, we're sorry that this fell under the radar. If you want to continue to work on this, just reopen the PR and/or ping a reviewer. |
Add the new lint `same_item_push` changelog: Add the new lint `same_item_push` Fixed #4078. As I said in #4078 (comment), I referrerd to #4647.
Add the new lint `same_item_push` changelog: Add the new lint `same_item_push` Fixed #4078. As I said in #4078 (comment), I referrerd to #4647.
Add the new lint `same_item_push` changelog: Add the new lint `same_item_push` Fixed #4078. As I said in #4078 (comment), I referrerd to #4647.
Add the new lint `same_item_push` changelog: Add the new lint `same_item_push` Fixed rust-lang#4078. As I said in rust-lang#4078 (comment), I referrerd to rust-lang#4647.
@rustbot label -S-inactive-closed |
This PR has an implementation for the lint suggested in issue #4078. Pushing the same item into a
Vec
can be done withvec![item; SIZE]
or withVec::resize()
. I did try to reduce false positives by not giving lints forfor
loops with conditional branching, loops, or multiple pushes.I noticed how problematic these things can be when I saw inside
src/ptr.rs
where the branching makes the loop terminate early. As a result, these kinds of loops are not considered for linting.Similarly,
src/booleans.rs
has multiple pushes which may occur in an iteration depending on some condition.changelog: New lint:
push_same_item