]> git.proxmox.com Git - rustc.git/blob - src/tools/clippy/src/docs/ineffective_bit_mask.txt
New upstream version 1.65.0+dfsg1
[rustc.git] / src / tools / clippy / src / docs / ineffective_bit_mask.txt
1 ### What it does
2 Checks for bit masks in comparisons which can be removed
3 without changing the outcome. The basic structure can be seen in the
4 following table:
5
6 |Comparison| Bit Op |Example |equals |
7 |----------|----------|------------|-------|
8 |`>` / `<=`|`\|` / `^`|`x \| 2 > 3`|`x > 3`|
9 |`<` / `>=`|`\|` / `^`|`x ^ 1 < 4` |`x < 4`|
10
11 ### Why is this bad?
12 Not equally evil as [`bad_bit_mask`](#bad_bit_mask),
13 but still a bit misleading, because the bit mask is ineffective.
14
15 ### Known problems
16 False negatives: This lint will only match instances
17 where we have figured out the math (which is for a power-of-two compared
18 value). This means things like `x | 1 >= 7` (which would be better written
19 as `x >= 6`) will not be reported (but bit masks like this are fairly
20 uncommon).
21
22 ### Example
23 ```
24 if (x | 1 > 3) { }
25 ```