Skip to content
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

Merged
merged 9 commits into from
Aug 10, 2020
Merged

Conversation

giraffate
Copy link
Contributor

changelog: Add the new lint same_item_push

Fixed #4078. As I said in #4078 (comment), I referrerd to #4647.

@rust-highfive
Copy link

r? @Manishearth

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jul 20, 2020
@giraffate
Copy link
Contributor Author

I couldn't run rustfmt at nightly so I haven't run rustfmt yet.

$ rustc -V
rustc 1.47.0-nightly (d7f945163 2020-07-19)
$ cargo dev fmt                 Finished dev [unoptimized + debuginfo] target(s) in 0.08s
     Running `clippy_dev/target/debug/clippy_dev fmt`
error: A command failed! `cd /Users/tnakata/workspace/rust-clippy && rustfmt +nightly --version`
$ rustfmt --version
error: the 'rustfmt' component which provides the command 'rustfmt' is not available for the 'nightly-x86_64-apple-darwin' toolchain

@giraffate
Copy link
Contributor Author

I run rustfmt in a little old nightly.

$ rustc -V
rustc 1.46.0-nightly (346aec9b0 2020-07-11)

@@ -1017,6 +1052,238 @@ fn detect_manual_memcpy<'tcx>(
}
}

// Delegate that traverses expression and detects mutable variables being used
struct UsesMutableDelegate {
Copy link
Member

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?

Copy link
Contributor Author

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?

}

// Scans for the usage of the for loop pattern
struct ForPatternVisitor<'a, 'tcx> {
Copy link
Member

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.

Copy link
Member

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

Copy link
Contributor Author

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?

@giraffate
Copy link
Contributor Author

Test failed where it seems unrelated.

@bors
Copy link
Collaborator

bors commented Aug 4, 2020

☔ The latest upstream changes (presumably #5868) made this pull request unmergeable. Please resolve the merge conflicts.

@giraffate
Copy link
Contributor Author

@Manishearth Thanks for your review! I fixed it and tests passed now, so could you take another look into this?

@Manishearth
Copy link
Member

@bors r+

@bors
Copy link
Collaborator

bors commented Aug 7, 2020

📌 Commit 610d4e3 has been approved by Manishearth

@bors
Copy link
Collaborator

bors commented Aug 7, 2020

⌛ Testing commit 610d4e3 with merge baab560...

bors added a commit that referenced this pull request Aug 7, 2020
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
Copy link
Collaborator

bors commented Aug 7, 2020

💔 Test failed - checks-action_test

@flip1995
Copy link
Member

flip1995 commented Aug 7, 2020

@bors retry

@bors
Copy link
Collaborator

bors commented Aug 7, 2020

⌛ Testing commit 610d4e3 with merge f39a457...

bors added a commit that referenced this pull request Aug 7, 2020
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.
@flip1995 flip1995 added S-waiting-on-bors Status: The marked PR was approved and is only waiting bors and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Aug 7, 2020
@bors
Copy link
Collaborator

bors commented Aug 7, 2020

💔 Test failed - checks-action_test

@flip1995
Copy link
Member

@bors retry

@bors
Copy link
Collaborator

bors commented Aug 10, 2020

⌛ Testing commit 610d4e3 with merge b79948a...

bors added a commit that referenced this pull request Aug 10, 2020
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.
@flip1995
Copy link
Member

@bors retry (yeet)

bors added a commit that referenced this pull request Aug 10, 2020
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
@bors
Copy link
Collaborator

bors commented Aug 10, 2020

⌛ Testing commit 610d4e3 with merge c576bed...

@bors bors merged commit 9da5b6d into rust-lang:master Aug 10, 2020
@giraffate giraffate deleted the same_item_push branch August 10, 2020 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: The marked PR was approved and is only waiting bors
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Suggest resize rather when pushing same item to vec
5 participants