Address arith-overflow and error-handling in const_eval.rs.
1. Detect and report arithmetic overflow during const-expr eval.
2. Instead `eval_const_expr_partial` returning `Err(String)`, it now
has a dedicated enum of different cases. The main benefit of this
is the ability to pass along an interpretable payload, namely the
two inputs that caused an overlfow.
I attempted to minimize fallout to error output in tests, but some was
unavoidable. Those changes are in a follow-on commit.
This commit is contained in:
parent
f9bbef7f44
commit
e919f82da1
6 changed files with 239 additions and 74 deletions
|
|
@ -9,8 +9,8 @@
|
|||
// except according to those terms.
|
||||
|
||||
enum test {
|
||||
div_zero = 1/0, //~ERROR expected constant: attempted to divide by zero
|
||||
rem_zero = 1%0 //~ERROR expected constant: attempted remainder with a divisor of zero
|
||||
div_zero = 1/0, //~ERROR constant evaluation error: attempted to divide by zero
|
||||
rem_zero = 1%0 //~ERROR constant evaluation error: attempted remainder with a divisor of zero
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue