diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index c1cc01ed05a72..d3619a247677d 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -299,9 +299,9 @@ pub fn eval_const_expr_partial(tcx: middle::ty::ctxt, e: @expr) add => Ok(const_int(a + b)), subtract => Ok(const_int(a - b)), mul => Ok(const_int(a * b)), - quot if b == 0 => Err(~"quotient zero"), + quot if b == 0 => Err(~"attempted quotient with a divisor of zero"), quot => Ok(const_int(a / b)), - rem if b == 0 => Err(~"remainder zero"), + rem if b == 0 => Err(~"attempted remainder with a divisor of zero"), rem => Ok(const_int(a % b)), and | bitand => Ok(const_int(a & b)), or | bitor => Ok(const_int(a | b)), @@ -321,9 +321,9 @@ pub fn eval_const_expr_partial(tcx: middle::ty::ctxt, e: @expr) add => Ok(const_uint(a + b)), subtract => Ok(const_uint(a - b)), mul => Ok(const_uint(a * b)), - quot if b == 0 => Err(~"quotient zero"), + quot if b == 0 => Err(~"attempted quotient with a divisor of zero"), quot => Ok(const_uint(a / b)), - rem if b == 0 => Err(~"remainder zero"), + rem if b == 0 => Err(~"attempted remainder with a divisor of zero"), rem => Ok(const_uint(a % b)), and | bitand => Ok(const_uint(a & b)), or | bitor => Ok(const_uint(a | b)), diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index da87568b3d0c0..de64441fd95bf 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -785,9 +785,9 @@ pub fn cast_shift_rhs(op: ast::binop, pub fn fail_if_zero(cx: block, span: span, quotrem: ast::binop, rhs: ValueRef, rhs_t: ty::t) -> block { let text = if quotrem == ast::quot { - @~"quotient zero" + @~"attempted quotient with a divisor of zero" } else { - @~"remainder zero" + @~"attempted remainder with a divisor of zero" }; let is_zero = match ty::get(rhs_t).sty { ty::ty_int(t) => { diff --git a/src/test/compile-fail/eval-enum.rs b/src/test/compile-fail/eval-enum.rs index d368f9d6769de..0123341957903 100644 --- a/src/test/compile-fail/eval-enum.rs +++ b/src/test/compile-fail/eval-enum.rs @@ -1,6 +1,6 @@ enum test { - quot_zero = 1/0, //~ERROR expected constant: quotient zero - rem_zero = 1%0 //~ERROR expected constant: remainder zero + quot_zero = 1/0, //~ERROR expected constant: attempted quotient with a divisor of zero + rem_zero = 1%0 //~ERROR expected constant: attempted remainder with a divisor of zero } fn main() {} diff --git a/src/test/run-fail/divide-by-zero.rs b/src/test/run-fail/divide-by-zero.rs index 7a17dd024153c..d4f3828ea7174 100644 --- a/src/test/run-fail/divide-by-zero.rs +++ b/src/test/run-fail/divide-by-zero.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:quotient zero +// error-pattern:attempted quotient with a divisor of zero fn main() { let y = 0; let z = 1 / y; diff --git a/src/test/run-fail/mod-zero.rs b/src/test/run-fail/mod-zero.rs index c379a8fc65fd7..b3e083c77fb23 100644 --- a/src/test/run-fail/mod-zero.rs +++ b/src/test/run-fail/mod-zero.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:remainder zero +// error-pattern:attempted remainder with a divisor of zero fn main() { let y = 0; let z = 1 % y;