### What it does Checks for incompatible bit masks in comparisons. The formula for detecting if an expression of the type `_ m c` (where `` is one of {`&`, `|`} and `` is one of {`!=`, `>=`, `>`, `!=`, `>=`, `>`}) can be determined from the following table: |Comparison |Bit Op|Example |is always|Formula | |------------|------|-------------|---------|----------------------| |`==` or `!=`| `&` |`x & 2 == 3` |`false` |`c & m != c` | |`<` or `>=`| `&` |`x & 2 < 3` |`true` |`m < c` | |`>` or `<=`| `&` |`x & 1 > 1` |`false` |`m <= c` | |`==` or `!=`| `\|` |`x \| 1 == 0`|`false` |`c \| m != c` | |`<` or `>=`| `\|` |`x \| 1 < 1` |`false` |`m >= c` | |`<=` or `>` | `\|` |`x \| 1 > 0` |`true` |`m > c` | ### Why is this bad? If the bits that the comparison cares about are always set to zero or one by the bit mask, the comparison is constant `true` or `false` (depending on mask, compared value, and operators). So the code is actively misleading, and the only reason someone would write this intentionally is to win an underhanded Rust contest or create a test-case for this lint. ### Example ``` if (x & 1 == 2) { } ```