2017-02-07 20:05:30 +00:00
|
|
|
error: this if-then-else expression returns a bool literal
|
2024-02-27 14:25:18 +00:00
|
|
|
--> tests/ui/needless_bool/fixable.rs:41:5
|
2017-02-07 20:05:30 +00:00
|
|
|
|
|
2018-12-27 15:57:55 +00:00
|
|
|
LL | / if x {
|
|
|
|
LL | | true
|
|
|
|
LL | | } else {
|
|
|
|
LL | | false
|
|
|
|
LL | | };
|
2018-12-10 05:27:19 +00:00
|
|
|
| |_____^ help: you can reduce it to: `x`
|
2019-08-05 20:05:05 +00:00
|
|
|
|
|
|
|
|
= note: `-D clippy::needless-bool` implied by `-D warnings`
|
2023-08-01 12:02:21 +00:00
|
|
|
= help: to override `-D warnings` add `#[allow(clippy::needless_bool)]`
|
2017-02-07 20:05:30 +00:00
|
|
|
|
|
|
|
error: this if-then-else expression returns a bool literal
|
2024-02-27 14:25:18 +00:00
|
|
|
--> tests/ui/needless_bool/fixable.rs:46:5
|
2017-02-07 20:05:30 +00:00
|
|
|
|
|
2018-12-27 15:57:55 +00:00
|
|
|
LL | / if x {
|
|
|
|
LL | | false
|
|
|
|
LL | | } else {
|
|
|
|
LL | | true
|
|
|
|
LL | | };
|
2018-12-10 05:27:19 +00:00
|
|
|
| |_____^ help: you can reduce it to: `!x`
|
2017-02-07 20:05:30 +00:00
|
|
|
|
|
|
|
error: this if-then-else expression returns a bool literal
|
2024-02-27 14:25:18 +00:00
|
|
|
--> tests/ui/needless_bool/fixable.rs:51:5
|
2017-02-07 20:05:30 +00:00
|
|
|
|
|
2018-12-27 15:57:55 +00:00
|
|
|
LL | / if x && y {
|
|
|
|
LL | | false
|
|
|
|
LL | | } else {
|
|
|
|
LL | | true
|
|
|
|
LL | | };
|
2018-12-10 05:27:19 +00:00
|
|
|
| |_____^ help: you can reduce it to: `!(x && y)`
|
2017-02-07 20:05:30 +00:00
|
|
|
|
2019-08-05 20:05:05 +00:00
|
|
|
error: this if-then-else expression returns a bool literal
|
2024-02-27 14:25:18 +00:00
|
|
|
--> tests/ui/needless_bool/fixable.rs:59:5
|
2021-12-30 14:10:43 +00:00
|
|
|
|
|
|
|
|
LL | / if a == b {
|
|
|
|
LL | | false
|
|
|
|
LL | | } else {
|
|
|
|
LL | | true
|
|
|
|
LL | | };
|
|
|
|
| |_____^ help: you can reduce it to: `a != b`
|
|
|
|
|
|
|
|
error: this if-then-else expression returns a bool literal
|
2024-02-27 14:25:18 +00:00
|
|
|
--> tests/ui/needless_bool/fixable.rs:64:5
|
2021-12-30 14:10:43 +00:00
|
|
|
|
|
|
|
|
LL | / if a != b {
|
|
|
|
LL | | false
|
|
|
|
LL | | } else {
|
|
|
|
LL | | true
|
|
|
|
LL | | };
|
|
|
|
| |_____^ help: you can reduce it to: `a == b`
|
|
|
|
|
|
|
|
error: this if-then-else expression returns a bool literal
|
2024-02-27 14:25:18 +00:00
|
|
|
--> tests/ui/needless_bool/fixable.rs:69:5
|
2021-12-30 14:10:43 +00:00
|
|
|
|
|
|
|
|
LL | / if a < b {
|
|
|
|
LL | | false
|
|
|
|
LL | | } else {
|
|
|
|
LL | | true
|
|
|
|
LL | | };
|
|
|
|
| |_____^ help: you can reduce it to: `a >= b`
|
|
|
|
|
|
|
|
error: this if-then-else expression returns a bool literal
|
2024-02-27 14:25:18 +00:00
|
|
|
--> tests/ui/needless_bool/fixable.rs:74:5
|
2021-12-30 14:10:43 +00:00
|
|
|
|
|
|
|
|
LL | / if a <= b {
|
|
|
|
LL | | false
|
|
|
|
LL | | } else {
|
|
|
|
LL | | true
|
|
|
|
LL | | };
|
|
|
|
| |_____^ help: you can reduce it to: `a > b`
|
|
|
|
|
|
|
|
error: this if-then-else expression returns a bool literal
|
2024-02-27 14:25:18 +00:00
|
|
|
--> tests/ui/needless_bool/fixable.rs:79:5
|
2021-12-30 14:10:43 +00:00
|
|
|
|
|
|
|
|
LL | / if a > b {
|
|
|
|
LL | | false
|
|
|
|
LL | | } else {
|
|
|
|
LL | | true
|
|
|
|
LL | | };
|
|
|
|
| |_____^ help: you can reduce it to: `a <= b`
|
|
|
|
|
|
|
|
error: this if-then-else expression returns a bool literal
|
2024-02-27 14:25:18 +00:00
|
|
|
--> tests/ui/needless_bool/fixable.rs:84:5
|
2021-12-30 14:10:43 +00:00
|
|
|
|
|
|
|
|
LL | / if a >= b {
|
|
|
|
LL | | false
|
|
|
|
LL | | } else {
|
|
|
|
LL | | true
|
|
|
|
LL | | };
|
|
|
|
| |_____^ help: you can reduce it to: `a < b`
|
|
|
|
|
|
|
|
error: this if-then-else expression returns a bool literal
|
2024-02-27 14:25:18 +00:00
|
|
|
--> tests/ui/needless_bool/fixable.rs:112:5
|
2017-02-07 20:05:30 +00:00
|
|
|
|
|
2018-12-27 15:57:55 +00:00
|
|
|
LL | / if x {
|
|
|
|
LL | | return true;
|
|
|
|
LL | | } else {
|
|
|
|
LL | | return false;
|
|
|
|
LL | | };
|
2019-08-05 20:05:05 +00:00
|
|
|
| |_____^ help: you can reduce it to: `return x`
|
2017-02-07 20:05:30 +00:00
|
|
|
|
|
|
|
error: this if-then-else expression returns a bool literal
|
2024-02-27 14:25:18 +00:00
|
|
|
--> tests/ui/needless_bool/fixable.rs:120:5
|
2018-12-27 15:57:55 +00:00
|
|
|
|
|
|
|
|
LL | / if x {
|
|
|
|
LL | | return false;
|
2019-08-05 20:05:05 +00:00
|
|
|
LL | | } else {
|
|
|
|
LL | | return true;
|
2018-12-27 15:57:55 +00:00
|
|
|
LL | | };
|
2019-08-05 20:05:05 +00:00
|
|
|
| |_____^ help: you can reduce it to: `return !x`
|
2017-02-07 20:05:30 +00:00
|
|
|
|
|
|
|
error: this if-then-else expression returns a bool literal
|
2024-02-27 14:25:18 +00:00
|
|
|
--> tests/ui/needless_bool/fixable.rs:128:5
|
2018-12-27 15:57:55 +00:00
|
|
|
|
|
|
|
|
LL | / if x && y {
|
|
|
|
LL | | return true;
|
|
|
|
LL | | } else {
|
|
|
|
LL | | return false;
|
|
|
|
LL | | };
|
|
|
|
| |_____^ help: you can reduce it to: `return x && y`
|
2017-02-07 20:05:30 +00:00
|
|
|
|
|
|
|
error: this if-then-else expression returns a bool literal
|
2024-02-27 14:25:18 +00:00
|
|
|
--> tests/ui/needless_bool/fixable.rs:136:5
|
2018-12-27 15:57:55 +00:00
|
|
|
|
|
|
|
|
LL | / if x && y {
|
|
|
|
LL | | return false;
|
|
|
|
LL | | } else {
|
|
|
|
LL | | return true;
|
|
|
|
LL | | };
|
|
|
|
| |_____^ help: you can reduce it to: `return !(x && y)`
|
2017-02-07 20:05:30 +00:00
|
|
|
|
2018-10-28 14:37:39 +00:00
|
|
|
error: equality checks against true are unnecessary
|
2024-02-27 14:25:18 +00:00
|
|
|
--> tests/ui/needless_bool/fixable.rs:144:8
|
2018-12-27 15:57:55 +00:00
|
|
|
|
|
|
|
|
LL | if x == true {};
|
|
|
|
| ^^^^^^^^^ help: try simplifying it as shown: `x`
|
|
|
|
|
|
|
|
|
= note: `-D clippy::bool-comparison` implied by `-D warnings`
|
2023-08-01 12:02:21 +00:00
|
|
|
= help: to override `-D warnings` add `#[allow(clippy::bool_comparison)]`
|
2018-10-28 14:37:39 +00:00
|
|
|
|
|
|
|
error: equality checks against false can be replaced by a negation
|
2024-02-27 14:25:18 +00:00
|
|
|
--> tests/ui/needless_bool/fixable.rs:148:8
|
2018-12-27 15:57:55 +00:00
|
|
|
|
|
|
|
|
LL | if x == false {};
|
|
|
|
| ^^^^^^^^^^ help: try simplifying it as shown: `!x`
|
2018-10-28 14:37:39 +00:00
|
|
|
|
|
|
|
error: equality checks against true are unnecessary
|
2024-02-27 14:25:18 +00:00
|
|
|
--> tests/ui/needless_bool/fixable.rs:158:8
|
2018-12-27 15:57:55 +00:00
|
|
|
|
|
|
|
|
LL | if x == true {};
|
|
|
|
| ^^^^^^^^^ help: try simplifying it as shown: `x`
|
2018-10-28 14:37:39 +00:00
|
|
|
|
|
|
|
error: equality checks against false can be replaced by a negation
|
2024-02-27 14:25:18 +00:00
|
|
|
--> tests/ui/needless_bool/fixable.rs:159:8
|
2018-12-27 15:57:55 +00:00
|
|
|
|
|
|
|
|
LL | if x == false {};
|
|
|
|
| ^^^^^^^^^^ help: try simplifying it as shown: `!x`
|
2018-10-28 14:37:39 +00:00
|
|
|
|
2019-01-20 15:15:00 +00:00
|
|
|
error: this if-then-else expression returns a bool literal
|
2024-02-27 14:25:18 +00:00
|
|
|
--> tests/ui/needless_bool/fixable.rs:168:12
|
2019-01-20 15:15:00 +00:00
|
|
|
|
|
|
|
|
LL | } else if returns_bool() {
|
|
|
|
| ____________^
|
|
|
|
LL | | false
|
|
|
|
LL | | } else {
|
|
|
|
LL | | true
|
|
|
|
LL | | };
|
2019-08-04 20:08:28 +00:00
|
|
|
| |_____^ help: you can reduce it to: `{ !returns_bool() }`
|
2019-01-20 15:15:00 +00:00
|
|
|
|
2021-12-17 12:40:22 +00:00
|
|
|
error: this if-then-else expression returns a bool literal
|
2024-02-27 14:25:18 +00:00
|
|
|
--> tests/ui/needless_bool/fixable.rs:181:5
|
2021-12-17 12:40:22 +00:00
|
|
|
|
|
|
|
|
LL | / if unsafe { no(4) } & 1 != 0 {
|
|
|
|
LL | | true
|
|
|
|
LL | | } else {
|
|
|
|
LL | | false
|
|
|
|
LL | | };
|
|
|
|
| |_____^ help: you can reduce it to: `(unsafe { no(4) } & 1 != 0)`
|
|
|
|
|
|
|
|
error: this if-then-else expression returns a bool literal
|
2024-02-27 14:25:18 +00:00
|
|
|
--> tests/ui/needless_bool/fixable.rs:186:30
|
2021-12-17 12:40:22 +00:00
|
|
|
|
|
|
|
|
LL | let _brackets_unneeded = if unsafe { no(4) } & 1 != 0 { true } else { false };
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `unsafe { no(4) } & 1 != 0`
|
|
|
|
|
|
|
|
error: this if-then-else expression returns a bool literal
|
2024-02-27 14:25:18 +00:00
|
|
|
--> tests/ui/needless_bool/fixable.rs:189:9
|
2021-12-17 12:40:22 +00:00
|
|
|
|
|
|
|
|
LL | if unsafe { no(4) } & 1 != 0 { true } else { false }
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `(unsafe { no(4) } & 1 != 0)`
|
|
|
|
|
2024-06-13 10:30:48 +00:00
|
|
|
error: this if-then-else expression returns a bool literal
|
|
|
|
--> tests/ui/needless_bool/fixable.rs:200:14
|
|
|
|
|
|
|
|
|
LL | let _x = if a && b { true } else { false }.then(|| todo!());
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `(a && b)`
|
|
|
|
|
|
|
|
error: this if-then-else expression returns a bool literal
|
|
|
|
--> tests/ui/needless_bool/fixable.rs:201:14
|
|
|
|
|
|
|
|
|
LL | let _x = if a && b { true } else { false } as u8;
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `(a && b)`
|
|
|
|
|
|
|
|
error: this if-then-else expression returns a bool literal
|
|
|
|
--> tests/ui/needless_bool/fixable.rs:204:14
|
|
|
|
|
|
|
|
|
LL | let _x = if a { true } else { false }.then(|| todo!());
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `a`
|
|
|
|
|
|
|
|
error: aborting due to 24 previous errors
|
2018-01-16 16:06:27 +00:00
|
|
|
|