Show values that lead to an arithmetic overflow when computing constants #71134
Labels
A-const-eval
Area: Constant evaluation, covers all const contexts (static, const fn, ...)
A-diagnostics
Area: Messages for errors, warnings, and lints
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
D-papercut
Diagnostics: An error or lint that needs small tweaks.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
In Rust 1.42, this code correctly fails due to a misuse of bitwise-XOR as exponentiation:
However, the error message could be enhanced to show the values that lead to the overflow. One rough idea:
This originated from a Stack Overflow question: How can I guarantee that overflow will not occur in const variables?
/cc @oli-obk
The text was updated successfully, but these errors were encountered: