Skip to content

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.

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
Contributor

bors commented Sep 25, 2019

📌 Commit 2f34576 has been approved by oli-obk

@bors
Copy link
Contributor

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
Contributor

bors commented Sep 25, 2019

💔 Test failed - status-appveyor

@matthiaskrgr
Copy link
Member

@bors retry

@bors
Copy link
Contributor

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
Contributor

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