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 a new lint for comparison chains #4569

Merged
merged 3 commits into from
Sep 26, 2019
Merged

Add a new lint for comparison chains #4569

merged 3 commits into from
Sep 26, 2019

Conversation

james9909
Copy link
Contributor

@james9909 james9909 commented Sep 24, 2019

changelog: Adds a new lint: comparison_chain.

comparison_chain lints all if conditional chains where all the conditions are binary comparisons on the same two operands and will suggest a rewrite with match.

Closes #4531.

clippy_lints/src/copies.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@oli-obk oli-obk left a comment

Choose a reason for hiding this comment

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

Awesome, thanks for working on this.

While I think this could be merged as is, it is also possible to emit a machine applicable suggestion. If you'd like to do that, too, we can either merge the PR and you open a new one adding the suggestion, or you can add it to this PR, whatever you prefer.

@james9909
Copy link
Contributor Author

@oli-obk Actually I think I'd be more comfortable with merging the branch as it is right now then opening another PR with the machine applicable suggestion in the future.

@oli-obk
Copy link
Contributor

oli-obk commented Sep 25, 2019

@bors r+

@bors
Copy link
Collaborator

bors commented Sep 25, 2019

📌 Commit 2f34576 has been approved by oli-obk

@bors
Copy link
Collaborator

bors commented Sep 25, 2019

⌛ Testing commit 2f34576 with merge 037e6a7...

bors added a commit that referenced this pull request Sep 25, 2019
Add a new lint for comparison chains

changelog: Adds a new lint: `comparison_chain`.

`comparison_chain` lints all `if` conditional chains where all the conditions are binary comparisons on the same two operands and will suggest a rewrite with `match`.

Closes #4531.
@bors
Copy link
Collaborator

bors commented Sep 25, 2019

💔 Test failed - status-appveyor

@matthiaskrgr
Copy link
Member

@bors retry

@bors
Copy link
Collaborator

bors commented Sep 26, 2019

⌛ Testing commit 2f34576 with merge 4d30b08...

bors added a commit that referenced this pull request Sep 26, 2019
Add a new lint for comparison chains

changelog: Adds a new lint: `comparison_chain`.

`comparison_chain` lints all `if` conditional chains where all the conditions are binary comparisons on the same two operands and will suggest a rewrite with `match`.

Closes #4531.
@bors
Copy link
Collaborator

bors commented Sep 26, 2019

☀️ Test successful - checks-travis, status-appveyor
Approved by: oli-obk
Pushing 4d30b08 to master...

@bors bors merged commit 2f34576 into rust-lang:master Sep 26, 2019
@james9909 james9909 deleted the add-comparison-chain branch September 29, 2019 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

suggest replacing if comparison chain with cmp match
4 participants