mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-30 08:30:45 +00:00
b3073c536b
CC #3770 From https://github.com/rust-lang/rust-clippy/issues/3770#issuecomment-687565594 (@flip1995): > Oh I thought I replied to this: I definitely see now that having this > as a correctness lint might be the wrong categorization. What we might > want to do is to just allow this lint, if there are comments in the > arm bodies. But a good first step would be to downgrade this lint to > style or complexity. I would vote for style since merging two arms is > not always less complex.
55 lines
1.6 KiB
Text
55 lines
1.6 KiB
Text
error: this if-then-else expression assigns a bool literal
|
|
--> $DIR/needless_bool_assign.rs:13:5
|
|
|
|
|
LL | / if random() && random() {
|
|
LL | | a.field = true;
|
|
LL | | } else {
|
|
LL | | a.field = false
|
|
LL | | }
|
|
| |_____^ help: you can reduce it to: `a.field = random() && random();`
|
|
|
|
|
= note: `-D clippy::needless-bool-assign` implied by `-D warnings`
|
|
= help: to override `-D warnings` add `#[allow(clippy::needless_bool_assign)]`
|
|
|
|
error: this if-then-else expression assigns a bool literal
|
|
--> $DIR/needless_bool_assign.rs:18:5
|
|
|
|
|
LL | / if random() && random() {
|
|
LL | | a.field = false;
|
|
LL | | } else {
|
|
LL | | a.field = true
|
|
LL | | }
|
|
| |_____^ help: you can reduce it to: `a.field = !(random() && random());`
|
|
|
|
error: this if-then-else expression assigns a bool literal
|
|
--> $DIR/needless_bool_assign.rs:32:5
|
|
|
|
|
LL | / if random() {
|
|
LL | | a.field = true;
|
|
LL | | } else {
|
|
LL | | a.field = true;
|
|
LL | | }
|
|
| |_____^ help: you can reduce it to: `random(); a.field = true;`
|
|
|
|
error: this `if` has identical blocks
|
|
--> $DIR/needless_bool_assign.rs:32:17
|
|
|
|
|
LL | if random() {
|
|
| _________________^
|
|
LL | | a.field = true;
|
|
LL | | } else {
|
|
| |_____^
|
|
|
|
|
note: same as this
|
|
--> $DIR/needless_bool_assign.rs:34:12
|
|
|
|
|
LL | } else {
|
|
| ____________^
|
|
LL | | a.field = true;
|
|
LL | | }
|
|
| |_____^
|
|
= note: `-D clippy::if-same-then-else` implied by `-D warnings`
|
|
= help: to override `-D warnings` add `#[allow(clippy::if_same_then_else)]`
|
|
|
|
error: aborting due to 4 previous errors
|
|
|