Open
Description
What it does
Detect const usize
/isize
values that correctly build for 64 bit targets but break the build with overflowing_literals
on 32 bit or 16 bit targets.
Advantage
- Detect obvious cases in which a program won't build for a different platform
- Detect incorrect uses of
usize
/isize
, and suggest replacing them withu64
/i64
Drawbacks
No response
Example
// Example 1
const VALUE: usize = 5000000000;
// Example 2
fn check(val: usize) -> bool {
val < 5000000000
}
Could be written as:
// Example 1
const VALUE: u64 = 5000000000;
// Example 2
fn check(val: u64) -> bool {
val < 5000000000
}