]> git.lizzy.rs Git - rust.git/blob - src/docs/invalid_upcast_comparisons.txt
Auto merge of #9421 - xphoniex:fix-#9420, r=giraffate
[rust.git] / src / docs / invalid_upcast_comparisons.txt
1 ### What it does
2 Checks for comparisons where the relation is always either
3 true or false, but where one side has been upcast so that the comparison is
4 necessary. Only integer types are checked.
5
6 ### Why is this bad?
7 An expression like `let x : u8 = ...; (x as u32) > 300`
8 will mistakenly imply that it is possible for `x` to be outside the range of
9 `u8`.
10
11 ### Known problems
12 https://github.com/rust-lang/rust-clippy/issues/886
13
14 ### Example
15 ```
16 let x: u8 = 1;
17 (x as u32) > 300;
18 ```