about summary refs log tree commit diff
path: root/src/docs/needless_bitwise_bool.txt
blob: fcd7b730aaae003ea7f6c88262dfdadc365bd634 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
### What it does
Checks for uses of bitwise and/or operators between booleans, where performance may be improved by using
a lazy and.

### Why is this bad?
The bitwise operators do not support short-circuiting, so it may hinder code performance.
Additionally, boolean logic "masked" as bitwise logic is not caught by lints like `unnecessary_fold`

### Known problems
This lint evaluates only when the right side is determined to have no side effects. At this time, that
determination is quite conservative.

### Example
```
let (x,y) = (true, false);
if x & !y {} // where both x and y are booleans
```
Use instead:
```
let (x,y) = (true, false);
if x && !y {}
```