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