]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/src/docs/absurd_extreme_comparisons.txt
Auto merge of #98559 - jackh726:remove-reempty, r=oli-obk
[rust.git] / src / tools / clippy / src / docs / absurd_extreme_comparisons.txt
1 ### What it does
2 Checks for comparisons where one side of the relation is
3 either the minimum or maximum value for its type and warns if it involves a
4 case that is always true or always false. Only integer and boolean types are
5 checked.
6
7 ### Why is this bad?
8 An expression like `min <= x` may misleadingly imply
9 that it is possible for `x` to be less than the minimum. Expressions like
10 `max < x` are probably mistakes.
11
12 ### Known problems
13 For `usize` the size of the current compile target will
14 be assumed (e.g., 64 bits on 64 bit systems). This means code that uses such
15 a comparison to detect target pointer width will trigger this lint. One can
16 use `mem::sizeof` and compare its value or conditional compilation
17 attributes
18 like `#[cfg(target_pointer_width = "64")] ..` instead.
19
20 ### Example
21 ```
22 let vec: Vec<isize> = Vec::new();
23 if vec.len() <= 0 {}
24 if 100 > i32::MAX {}
25 ```