-
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
Add the new lint same_item_push
#5825
Conversation
r? @Manishearth (rust_highfive has picked a reviewer for you, use r? to override) |
I couldn't run rustfmt at nightly so I haven't run rustfmt yet.
|
I run rustfmt in a little old nightly.
|
clippy_lints/src/loops.rs
Outdated
@@ -1017,6 +1052,238 @@ fn detect_manual_memcpy<'tcx>( | |||
} | |||
} | |||
|
|||
// Delegate that traverses expression and detects mutable variables being used | |||
struct UsesMutableDelegate { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this stuff be in utils
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used mutated_variables
in utils. How about this?
clippy_lints/src/loops.rs
Outdated
} | ||
|
||
// Scans for the usage of the for loop pattern | ||
struct ForPatternVisitor<'a, 'tcx> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems unnecessary, we just need to walk and look for a path that overlaps, we don't need to do any highly bespoke visiting for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's actually better to just check if the for pattern contains any new bindings (i.e. it only contains _
and constants). Unused bindings will be warned about by the unused variable lint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your review! I fixed to just check if for pattern
contains _
in 5670bc6. Is my understanding correct?
Test failed where it seems unrelated. |
☔ The latest upstream changes (presumably #5868) made this pull request unmergeable. Please resolve the merge conflicts. |
5670bc6
to
e48685e
Compare
@Manishearth Thanks for your review! I fixed it and tests passed now, so could you take another look into this? |
@bors r+ |
📌 Commit 610d4e3 has been approved by |
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.
💔 Test failed - checks-action_test |
@bors retry |
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.
💔 Test failed - checks-action_test |
@bors retry |
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.
@bors retry (yeet) |
Rollup of 5 pull requests Successful merges: - #5825 (Add the new lint `same_item_push`) - #5869 (New lint against `Self` as an arbitrary self type) - #5870 (enable #[allow(clippy::unsafe_derive_deserialize)]) - #5871 (Lint .min(x).max(y) with x < y) - #5874 (Make the docs clearer for new contributors) Failed merges: r? @ghost changelog: rollup
changelog: Add the new lint
same_item_push
Fixed #4078. As I said in #4078 (comment), I referrerd to #4647.