rust-clippy icon indicating copy to clipboard operation
rust-clippy copied to clipboard

fix incorrect suggestion for `!(a >= b) as i32 == c`

Open CoCo-Japan-pan opened this issue 1 year ago • 4 comments

fixes #12761

The expression !(a >= b) as i32 == c got simplified to a < b as i32 == c, but this is a syntax error. The result we want is (a < b) as i32 == c. This is fixed by adding a parenthesis to the suggestion given in check_simplify_not when the boolean expression is casted.

changelog: [nonminimal_bool]: fix incorrect suggestion for !(a >= b) as i32 == c

CoCo-Japan-pan avatar Sep 03 '24 14:09 CoCo-Japan-pan