Skip to content

Clippy suggests the same boolean expression as the code #4548

Closed
@betseg

Description

@betseg

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingL-suggestionLint: Improving, adding or fixing lint suggestions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions