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

Clippy suggests the same boolean expression as the code #4548

Closed
betseg opened this issue Sep 16, 2019 · 1 comment · Fixed by #4568
Closed

Clippy suggests the same boolean expression as the code #4548

betseg opened this issue Sep 16, 2019 · 1 comment · Fixed by #4568
Labels
C-bug Category: Clippy is not doing the correct thing L-suggestion Lint: Improving, adding or fixing lint suggestions

Comments

@betseg
Copy link

betseg commented Sep 16, 2019

Context: I have a piece of code to check if a matrix is a unit matrix:

if i != j && self[[i, j]] != 0 || i == j && self[[i, j]] != 1 {

and Clippy thinks it's not minimal and suggest the same code:

warning: this boolean expression can be simplified
  --> src/lib.rs:73:20
   |
73 |                 if i != j && self[[i, j]] != 0 || i == j && self[[i, j]] != 1 {
   |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i != j && self[[i, j]] != 0 || i == j && self[[i, j]] != 1`
   |
   = note: #[warn(clippy::nonminimal_bool)] on by default
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonminimal_bool

Version info:

$ cargo clippy -V
clippy 0.0.212 (e3cb40e 2019-06-25)
@JohnTitor JohnTitor added the L-suggestion Lint: Improving, adding or fixing lint suggestions label Sep 16, 2019
@flip1995 flip1995 added the C-bug Category: Clippy is not doing the correct thing label Sep 17, 2019
@ghost
Copy link

ghost commented Sep 23, 2019

I'm looking at this. The reason for the error is that we change i == j to NOT(i != j) when translating to QMM and then think we've found a simplification when we change it back while generating suggestions.

This is probably the same error as #3847

bors added a commit that referenced this issue Sep 25, 2019
Fix `nonminimal-bool` false positive

Closes #4548
Closes #3847

changelog: Fix `nonminimal-bool` false positive
bors added a commit that referenced this issue Sep 26, 2019
Fix `nonminimal-bool` false positive

Closes #4548
Closes #3847

changelog: Fix `nonminimal-bool` false positive
@bors bors closed this as completed in 0cc48ad Sep 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing L-suggestion Lint: Improving, adding or fixing lint suggestions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants