blob: e4ae57304141abd67215616b3589d5b83e888410 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
error: boolean to int conversion using if
--> tests/ui/bool_to_int_with_if.rs:13:5
|
LL | / if a {
LL | |
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
= note: `-D clippy::bool-to-int-with-if` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::bool_to_int_with_if)]`
error: boolean to int conversion using if
--> tests/ui/bool_to_int_with_if.rs:19:5
|
LL | / if a {
LL | |
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
--> tests/ui/bool_to_int_with_if.rs:25:5
|
LL | / if !a {
LL | |
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
error: boolean to int conversion using if
--> tests/ui/bool_to_int_with_if.rs:31:5
|
LL | / if a || b {
LL | |
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
--> tests/ui/bool_to_int_with_if.rs:37:5
|
LL | / if cond(a, b) {
LL | |
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
--> tests/ui/bool_to_int_with_if.rs:43:5
|
LL | / if x + y < 4 {
LL | |
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
--> tests/ui/bool_to_int_with_if.rs:53:12
|
LL | } else if b {
| ____________^
LL | |
LL | | 1
LL | | } else {
LL | | 0
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
--> tests/ui/bool_to_int_with_if.rs:63:12
|
LL | } else if b {
| ____________^
LL | |
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
--> tests/ui/bool_to_int_with_if.rs:129:5
|
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
error: boolean to int conversion using if
--> tests/ui/bool_to_int_with_if.rs:173:13
|
LL | let _ = if dbg!(4 > 0) { 1 } else { 0 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with from: `i32::from(dbg!(4 > 0))`
|
= note: `dbg!(4 > 0) as i32` or `dbg!(4 > 0).into()` can also be valid options
error: boolean to int conversion using if
--> tests/ui/bool_to_int_with_if.rs:176:18
|
LL | let _ = dbg!(if 4 > 0 { 1 } else { 0 });
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with from: `i32::from(4 > 0)`
|
= note: `(4 > 0) as i32` or `(4 > 0).into()` can also be valid options
error: aborting due to 11 previous errors
|