Skip to content

Implements lint for order comparisons against bool (#3438) #3556

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

Merged
merged 2 commits into from
Dec 18, 2018

Conversation

lucasloisp
Copy link
Contributor

As described on issue #3438, this change implements linting for > and < comparisons against both boolean literals and between expressions.

--> $DIR/bool_comparison.rs:74:8
|
74 | if x < y {
| ^^^^^ help: try simplifying it as shown: `!x && y`
Copy link
Contributor

Choose a reason for hiding this comment

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

The suggestion is not identical if x or y have side effects. I think we should use & here so that both sides are evaluated. We can leave it to the user to use && or add a performance lint about changing & to && in the future

Copy link
Member

Choose a reason for hiding this comment

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

The lint about & vs && is practically finished: #3385, just needs tests and doc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems great, just uploaded new changes

@oli-obk
Copy link
Contributor

oli-obk commented Dec 18, 2018

@bors r+

@bors
Copy link
Contributor

bors commented Dec 18, 2018

📌 Commit de42dfb has been approved by oli-obk

@bors
Copy link
Contributor

bors commented Dec 18, 2018

⌛ Testing commit de42dfb with merge 176778f...

bors added a commit that referenced this pull request Dec 18, 2018
Implements lint for order comparisons against bool (#3438)

As described on issue #3438, this change implements linting for `>` and `<` comparisons against both `boolean` literals and between expressions.
@bors
Copy link
Contributor

bors commented Dec 18, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: oli-obk
Pushing 176778f to master...

@bors bors merged commit de42dfb into rust-lang:master Dec 18, 2018
@lucasloisp lucasloisp deleted the bool-ord-comparison branch December 18, 2018 13:19
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.

4 participants