Closed
Description
#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
.
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Category: An issue proposing an enhancement or a PR with one.Diagnostics: An error or lint that needs small tweaks.Relevant to the compiler team, which will review and decide on the PR/issue.