You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Handle negative literals in cast overflow warning #48535
#48432 introduced a warning note explaining why a given literal falls outside of the size of the expected type.
In the case of negative literals, the output can be confusing:
warning: literal out of range for i8
--> $DIR/type-overflow.rs:34:17
|
34 | let fail = -0b1111_1111i8; //~WARNING literal out of range for i8
| ^^^^^^^^^^^^^ help: consider using `i16` instead: `0b1111_1111i16`
|
= note: the literal `0b1111_1111i8` (decimal `255`) does not fit into an `i8` and will become `-1i8`
fail will end up with the value 1, as the binary literal evaluates to -1, but it is negated again. The warning should be extended to catch this case and either modify the existing note/label, or add an extra note explaining that the value is being affected further by the outer -, resulting in the final value 1.
Activity
Rollup merge of rust-lang#82829 - JohnTitor:handle-neg-val, r=estebank