Description
Integer casts currently warn about possible precision loss even when the value is provably safe from surrounding conditions.
Warnings should be suppressed when the value range is known to be safe.
Example
a: i8 := ...
if a >= 0 {
// a ∈ [0, I8_MAX]
b: u8 := a as u8 // should NOT warn
}
c: u8 := a as u8 // should warn
Rule
A cast is safe if:
range(source) ⊆ range(target)
Benefit
- Removes false precision-loss warnings
- Improves static analysis
Description
Integer casts currently warn about possible precision loss even when the value is provably safe from surrounding conditions.
Warnings should be suppressed when the value range is known to be safe.
Example
Rule
A cast is safe if:
Benefit