2022-09-09 11:36:26 +00:00
|
|
|
error: boolean to int conversion using if
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/bool_to_int_with_if.rs:14:5
|
2022-09-09 11:36:26 +00:00
|
|
|
|
|
|
|
|
LL | / if a {
|
|
|
|
LL | | 1
|
|
|
|
LL | | } else {
|
|
|
|
LL | | 0
|
|
|
|
LL | | };
|
|
|
|
| |_____^ help: replace with from: `i32::from(a)`
|
|
|
|
|
|
|
|
|
= note: `a as i32` or `a.into()` can also be valid options
|
2022-09-22 16:04:22 +00:00
|
|
|
= note: `-D clippy::bool-to-int-with-if` implied by `-D warnings`
|
2023-08-01 12:02:21 +00:00
|
|
|
= help: to override `-D warnings` add `#[allow(clippy::bool_to_int_with_if)]`
|
2022-09-09 11:36:26 +00:00
|
|
|
|
|
|
|
error: boolean to int conversion using if
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/bool_to_int_with_if.rs:19:5
|
2022-09-09 11:36:26 +00:00
|
|
|
|
|
2022-09-21 17:02:37 +00:00
|
|
|
LL | / if a {
|
|
|
|
LL | | 0
|
|
|
|
LL | | } else {
|
|
|
|
LL | | 1
|
|
|
|
LL | | };
|
|
|
|
| |_____^ help: replace with from: `i32::from(!a)`
|
|
|
|
|
|
|
|
|
= note: `!a as i32` or `(!a).into()` can also be valid options
|
|
|
|
|
|
|
|
error: boolean to int conversion using if
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/bool_to_int_with_if.rs:24:5
|
2022-09-21 17:02:37 +00:00
|
|
|
|
|
2022-09-09 11:36:26 +00:00
|
|
|
LL | / if !a {
|
|
|
|
LL | | 1
|
|
|
|
LL | | } else {
|
|
|
|
LL | | 0
|
|
|
|
LL | | };
|
|
|
|
| |_____^ help: replace with from: `i32::from(!a)`
|
|
|
|
|
|
2022-09-21 17:02:37 +00:00
|
|
|
= note: `!a as i32` or `(!a).into()` can also be valid options
|
2022-09-09 11:36:26 +00:00
|
|
|
|
|
|
|
error: boolean to int conversion using if
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/bool_to_int_with_if.rs:29:5
|
2022-09-09 11:36:26 +00:00
|
|
|
|
|
|
|
|
LL | / if a || b {
|
|
|
|
LL | | 1
|
|
|
|
LL | | } else {
|
|
|
|
LL | | 0
|
|
|
|
LL | | };
|
|
|
|
| |_____^ help: replace with from: `i32::from(a || b)`
|
|
|
|
|
|
|
|
|
= note: `(a || b) as i32` or `(a || b).into()` can also be valid options
|
|
|
|
|
|
|
|
error: boolean to int conversion using if
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/bool_to_int_with_if.rs:34:5
|
2022-09-09 11:36:26 +00:00
|
|
|
|
|
|
|
|
LL | / if cond(a, b) {
|
|
|
|
LL | | 1
|
|
|
|
LL | | } else {
|
|
|
|
LL | | 0
|
|
|
|
LL | | };
|
|
|
|
| |_____^ help: replace with from: `i32::from(cond(a, b))`
|
|
|
|
|
|
|
|
|
= note: `cond(a, b) as i32` or `cond(a, b).into()` can also be valid options
|
|
|
|
|
|
|
|
error: boolean to int conversion using if
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/bool_to_int_with_if.rs:39:5
|
2022-09-09 11:36:26 +00:00
|
|
|
|
|
|
|
|
LL | / if x + y < 4 {
|
|
|
|
LL | | 1
|
|
|
|
LL | | } else {
|
|
|
|
LL | | 0
|
|
|
|
LL | | };
|
|
|
|
| |_____^ help: replace with from: `i32::from(x + y < 4)`
|
|
|
|
|
|
|
|
|
= note: `(x + y < 4) as i32` or `(x + y < 4).into()` can also be valid options
|
|
|
|
|
|
|
|
error: boolean to int conversion using if
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/bool_to_int_with_if.rs:48:12
|
2022-09-09 11:36:26 +00:00
|
|
|
|
|
|
|
|
LL | } else if b {
|
|
|
|
| ____________^
|
|
|
|
LL | | 1
|
|
|
|
LL | | } else {
|
|
|
|
LL | | 0
|
|
|
|
LL | | };
|
2022-09-21 17:02:37 +00:00
|
|
|
| |_____^ help: replace with from: `{ i32::from(b) }`
|
2022-09-09 11:36:26 +00:00
|
|
|
|
|
|
|
|
= note: `b as i32` or `b.into()` can also be valid options
|
|
|
|
|
|
|
|
error: boolean to int conversion using if
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/bool_to_int_with_if.rs:57:12
|
2022-09-21 17:02:37 +00:00
|
|
|
|
|
|
|
|
LL | } else if b {
|
|
|
|
| ____________^
|
|
|
|
LL | | 0
|
|
|
|
LL | | } else {
|
|
|
|
LL | | 1
|
|
|
|
LL | | };
|
|
|
|
| |_____^ help: replace with from: `{ i32::from(!b) }`
|
|
|
|
|
|
|
|
|
= note: `!b as i32` or `(!b).into()` can also be valid options
|
|
|
|
|
|
|
|
error: boolean to int conversion using if
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/bool_to_int_with_if.rs:122:5
|
2022-09-09 11:36:26 +00:00
|
|
|
|
|
|
|
|
LL | if a { 1 } else { 0 }
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^ help: replace with from: `u8::from(a)`
|
|
|
|
|
|
|
|
|
= note: `a as u8` or `a.into()` can also be valid options
|
|
|
|
|
2022-09-21 17:02:37 +00:00
|
|
|
error: aborting due to 9 previous errors
|
2022-09-09 11:36:26 +00:00
|
|
|
|