Closed
Description
Part of #3630
Given the following code:
#![warn(clippy::needless_bool)]
let returns_bool = || false;
let x = if b {
true
} else if returns_bool() {
false
} else {
true
};
we currently provide a broken suggestion:
LL | } else if returns_bool() {
| ____________^
LL | | false
LL | | } else {
LL | | true
LL | | };
| |_____^ help: you can reduce it to: `!returns_bool()`
Applying the suggestion results in a syntax error:
let x = if b {
true
} else !returns_bool();
The suggestion should be { !returns_bool() }
- as it was before this PR: rust-lang/rust#61074