Skip to content

Update wording on E0080 #35283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/librustc/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ code example:
#[deny(const_err)]

const X: i32 = 42 / 0;
// error: attempted to divide by zero in a constant expression
// error: attempt to divide by zero in a constant expression
```
"##,

Expand Down
22 changes: 11 additions & 11 deletions src/librustc_const_math/err.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,18 @@ impl ConstMathErr {
UnequalTypes(BitOr) => "tried to bitor two values of different types",
UnequalTypes(BitXor) => "tried to xor two values of different types",
UnequalTypes(_) => unreachable!(),
Overflow(Add) => "attempted to add with overflow",
Overflow(Sub) => "attempted to subtract with overflow",
Overflow(Mul) => "attempted to multiply with overflow",
Overflow(Div) => "attempted to divide with overflow",
Overflow(Rem) => "attempted to calculate the remainder with overflow",
Overflow(Neg) => "attempted to negate with overflow",
Overflow(Shr) => "attempted to shift right with overflow",
Overflow(Shl) => "attempted to shift left with overflow",
Overflow(Add) => "attempt to add with overflow",
Overflow(Sub) => "attempt to subtract with overflow",
Overflow(Mul) => "attempt to multiply with overflow",
Overflow(Div) => "attempt to divide with overflow",
Overflow(Rem) => "attempt to calculate the remainder with overflow",
Overflow(Neg) => "attempt to negate with overflow",
Overflow(Shr) => "attempt to shift right with overflow",
Overflow(Shl) => "attempt to shift left with overflow",
Overflow(_) => unreachable!(),
ShiftNegative => "attempted to shift by a negative amount",
DivisionByZero => "attempted to divide by zero",
RemainderByZero => "attempted to calculate the remainder with a divisor of zero",
ShiftNegative => "attempt to shift by a negative amount",
DivisionByZero => "attempt to divide by zero",
RemainderByZero => "attempt to calculate the remainder with a divisor of zero",
UnsignedNegation => "unary negation of unsigned integer",
ULitOutOfRange(ast::UintTy::U8) => "literal out of range for u8",
ULitOutOfRange(ast::UintTy::U16) => "literal out of range for u16",
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1512,7 +1512,7 @@ fn trans_unary<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
C_integral(llty, min, true), debug_loc);
with_cond(bcx, is_min, |bcx| {
let msg = InternedString::new(
"attempted to negate with overflow");
"attempt to negate with overflow");
controlflow::trans_fail(bcx, expr_info(expr), msg)
})
} else {
Expand Down
8 changes: 4 additions & 4 deletions src/test/compile-fail/const-err-early.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
#![feature(const_indexing)]
#![deny(const_err)]

pub const A: i8 = -std::i8::MIN; //~ ERROR attempted to negate with overflow
pub const B: u8 = 200u8 + 200u8; //~ ERROR attempted to add with overflow
pub const C: u8 = 200u8 * 4; //~ ERROR attempted to multiply with overflow
pub const D: u8 = 42u8 - (42u8 + 1); //~ ERROR attempted to subtract with overflow
pub const A: i8 = -std::i8::MIN; //~ ERROR attempt to negate with overflow
pub const B: u8 = 200u8 + 200u8; //~ ERROR attempt to add with overflow
pub const C: u8 = 200u8 * 4; //~ ERROR attempt to multiply with overflow
pub const D: u8 = 42u8 - (42u8 + 1); //~ ERROR attempt to subtract with overflow
pub const E: u8 = [5u8][1];
//~^ ERROR index out of bounds: the len is 1 but the index is 1

Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/const-err-multi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#![deny(const_err)]

pub const A: i8 = -std::i8::MIN; //~ ERROR attempted to negate with overflow
pub const A: i8 = -std::i8::MIN; //~ ERROR attempt to negate with overflow
pub const B: i8 = A;
pub const C: u8 = A as u8;
pub const D: i8 = 50 - A;
Expand Down
10 changes: 5 additions & 5 deletions src/test/compile-fail/const-err.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ const FOO: u8 = [5u8][1];
fn main() {
let a = -std::i8::MIN;
//~^ WARN this expression will panic at run-time
//~| attempted to negate with overflow
//~| attempt to negate with overflow
let b = 200u8 + 200u8 + 200u8;
//~^ WARN this expression will panic at run-time
//~| attempted to add with overflow
//~| attempt to add with overflow
//~^^^ WARN this expression will panic at run-time
//~| attempted to add with overflow
//~| attempt to add with overflow
let c = 200u8 * 4;
//~^ WARN this expression will panic at run-time
//~| attempted to multiply with overflow
//~| attempt to multiply with overflow
let d = 42u8 - (42u8 + 1);
//~^ WARN this expression will panic at run-time
//~| attempted to subtract with overflow
//~| attempt to subtract with overflow
let _e = [5u8][1];
//~^ WARN this expression will panic at run-time
//~| index out of bounds: the len is 1 but the index is 1
Expand Down
10 changes: 5 additions & 5 deletions src/test/compile-fail/const-err2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ fn black_box<T>(_: T) {

fn main() {
let a = -std::i8::MIN;
//~^ ERROR attempted to negate with overflow
//~^ ERROR attempt to negate with overflow
let b = 200u8 + 200u8 + 200u8;
//~^ ERROR attempted to add with overflow
//~| ERROR attempted to add with overflow
//~^ ERROR attempt to add with overflow
//~| ERROR attempt to add with overflow
let c = 200u8 * 4;
//~^ ERROR attempted to multiply with overflow
//~^ ERROR attempt to multiply with overflow
let d = 42u8 - (42u8 + 1);
//~^ ERROR attempted to subtract with overflow
//~^ ERROR attempt to subtract with overflow
let _e = [5u8][1];
black_box(a);
black_box(b);
Expand Down
6 changes: 3 additions & 3 deletions src/test/compile-fail/const-eval-overflow-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ use std::{u8, u16, u32, u64, usize};
const NEG_128: i8 = -128;
const NEG_NEG_128: i8 = -NEG_128;
//~^ ERROR constant evaluation error
//~| attempted to negate with overflow
//~| attempt to negate with overflow
//~| ERROR constant evaluation error
//~| attempted to negate with overflow
//~| attempt to negate with overflow
//~| ERROR constant evaluation error
//~| attempted to negate with overflow
//~| attempt to negate with overflow

fn main() {
match -128i8 {
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/const-eval-overflow-3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// self-hosted and a cross-compiled setup; therefore resorting to
// error-pattern for now.

// error-pattern: attempted to add with overflow
// error-pattern: attempt to add with overflow

#![allow(unused_imports)]

Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/const-eval-overflow-4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use std::{u8, u16, u32, u64, usize};

const A_I8_T
: [u32; (i8::MAX as i8 + 1i8) as usize]
//~^ ERROR error evaluating count: attempted to add with overflow
//~^ ERROR error evaluating count: attempt to add with overflow
= [0; (i8::MAX as usize) + 1];

fn main() {
Expand Down
56 changes: 28 additions & 28 deletions src/test/compile-fail/const-eval-overflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,113 +22,113 @@ use std::{u8, u16, u32, u64, usize};
const VALS_I8: (i8, i8, i8, i8) =
(-i8::MIN,
//~^ ERROR constant evaluation error
//~| attempted to negate with overflow
//~| attempt to negate with overflow
i8::MIN - 1,
//~^ ERROR constant evaluation error
//~| attempted to subtract with overflow
//~| attempt to subtract with overflow
i8::MAX + 1,
//~^ ERROR constant evaluation error
//~| attempted to add with overflow
//~| attempt to add with overflow
i8::MIN * 2,
//~^ ERROR constant evaluation error
//~| attempted to multiply with overflow
//~| attempt to multiply with overflow
);

const VALS_I16: (i16, i16, i16, i16) =
(-i16::MIN,
//~^ ERROR constant evaluation error
//~| attempted to negate with overflow
//~| attempt to negate with overflow
i16::MIN - 1,
//~^ ERROR constant evaluation error
//~| attempted to subtract with overflow
//~| attempt to subtract with overflow
i16::MAX + 1,
//~^ ERROR constant evaluation error
//~| attempted to add with overflow
//~| attempt to add with overflow
i16::MIN * 2,
//~^ ERROR constant evaluation error
//~| attempted to multiply with overflow
//~| attempt to multiply with overflow
);

const VALS_I32: (i32, i32, i32, i32) =
(-i32::MIN,
//~^ ERROR constant evaluation error
//~| attempted to negate with overflow
//~| attempt to negate with overflow
i32::MIN - 1,
//~^ ERROR constant evaluation error
//~| attempted to subtract with overflow
//~| attempt to subtract with overflow
i32::MAX + 1,
//~^ ERROR constant evaluation error
//~| attempted to add with overflow
//~| attempt to add with overflow
i32::MIN * 2,
//~^ ERROR constant evaluation error
//~| attempted to multiply with overflow
//~| attempt to multiply with overflow
);

const VALS_I64: (i64, i64, i64, i64) =
(-i64::MIN,
//~^ ERROR constant evaluation error
//~| attempted to negate with overflow
//~| attempt to negate with overflow
i64::MIN - 1,
//~^ ERROR constant evaluation error
//~| attempted to subtract with overflow
//~| attempt to subtract with overflow
i64::MAX + 1,
//~^ ERROR constant evaluation error
//~| attempted to add with overflow
//~| attempt to add with overflow
i64::MAX * 2,
//~^ ERROR constant evaluation error
//~| attempted to multiply with overflow
//~| attempt to multiply with overflow
);

const VALS_U8: (u8, u8, u8, u8) =
(-(u8::MIN as i8) as u8,
u8::MIN - 1,
//~^ ERROR constant evaluation error
//~| attempted to subtract with overflow
//~| attempt to subtract with overflow
u8::MAX + 1,
//~^ ERROR constant evaluation error
//~| attempted to add with overflow
//~| attempt to add with overflow
u8::MAX * 2,
//~^ ERROR constant evaluation error
//~| attempted to multiply with overflow
//~| attempt to multiply with overflow
);

const VALS_U16: (u16, u16, u16, u16) =
(-(u16::MIN as i16) as u16,
u16::MIN - 1,
//~^ ERROR constant evaluation error
//~| attempted to subtract with overflow
//~| attempt to subtract with overflow
u16::MAX + 1,
//~^ ERROR constant evaluation error
//~| attempted to add with overflow
//~| attempt to add with overflow
u16::MAX * 2,
//~^ ERROR constant evaluation error
//~| attempted to multiply with overflow
//~| attempt to multiply with overflow
);

const VALS_U32: (u32, u32, u32, u32) =
(-(u32::MIN as i32) as u32,
u32::MIN - 1,
//~^ ERROR constant evaluation error
//~| attempted to subtract with overflow
//~| attempt to subtract with overflow
u32::MAX + 1,
//~^ ERROR constant evaluation error
//~| attempted to add with overflow
//~| attempt to add with overflow
u32::MAX * 2,
//~^ ERROR constant evaluation error
//~| attempted to multiply with overflow
//~| attempt to multiply with overflow
);

const VALS_U64: (u64, u64, u64, u64) =
(-(u64::MIN as i64) as u64,
u64::MIN - 1,
//~^ ERROR constant evaluation error
//~| attempted to subtract with overflow
//~| attempt to subtract with overflow
u64::MAX + 1,
//~^ ERROR constant evaluation error
//~| attempted to add with overflow
//~| attempt to add with overflow
u64::MAX * 2,
//~^ ERROR constant evaluation error
//~| attempted to multiply with overflow
//~| attempt to multiply with overflow
);

fn main() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const ONE: usize = 1;
const TWO: usize = 2;
const LEN: usize = ONE - TWO;
//~^ ERROR E0080
//~| attempted to subtract with overflow
//~| attempt to subtract with overflow

fn main() {
let a: [i8; LEN] = unimplemented!();
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/const-len-underflow-subspans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ const TWO: usize = 2;
fn main() {
let a: [i8; ONE - TWO] = unimplemented!();
//~^ ERROR constant evaluation error [E0080]
//~| attempted to subtract with overflow
//~| attempt to subtract with overflow
}
2 changes: 1 addition & 1 deletion src/test/compile-fail/const-tup-index-span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

const TUP: (usize,) = 5 << 64;
//~^ ERROR E0080
//~| attempted to shift left with overflow
//~| attempt to shift left with overflow
const ARR: [i32; TUP.0] = [];

fn main() {
Expand Down
4 changes: 2 additions & 2 deletions src/test/compile-fail/eval-enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

enum test {
div_zero = 1/0, //~ ERROR E0080
//~| attempted to divide by zero
//~| attempt to divide by zero
rem_zero = 1%0,
//~^ ERROR E0080
//~| attempted to calculate the remainder with a divisor of zero
//~| attempt to calculate the remainder with a divisor of zero
}

fn main() {}
40 changes: 20 additions & 20 deletions src/test/compile-fail/issue-8460-const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,43 +15,43 @@ use std::thread;

fn main() {
assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err());
//~^ ERROR attempted to divide with overflow
//~^ ERROR attempt to divide with overflow
assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err());
//~^ ERROR attempted to divide with overflow
//~^ ERROR attempt to divide with overflow
assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err());
//~^ ERROR attempted to divide with overflow
//~^ ERROR attempt to divide with overflow
assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err());
//~^ ERROR attempted to divide with overflow
//~^ ERROR attempt to divide with overflow
assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err());
//~^ ERROR attempted to divide with overflow
//~^ ERROR attempt to divide with overflow
assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err());
//~^ ERROR attempted to divide by zero
//~^ ERROR attempt to divide by zero
assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err());
//~^ ERROR attempted to divide by zero
//~^ ERROR attempt to divide by zero
assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err());
//~^ ERROR attempted to divide by zero
//~^ ERROR attempt to divide by zero
assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err());
//~^ ERROR attempted to divide by zero
//~^ ERROR attempt to divide by zero
assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err());
//~^ ERROR attempted to divide by zero
//~^ ERROR attempt to divide by zero
assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err());
//~^ ERROR attempted to calculate the remainder with overflow
//~^ ERROR attempt to calculate the remainder with overflow
assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err());
//~^ ERROR attempted to calculate the remainder with overflow
//~^ ERROR attempt to calculate the remainder with overflow
assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err());
//~^ ERROR attempted to calculate the remainder with overflow
//~^ ERROR attempt to calculate the remainder with overflow
assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err());
//~^ ERROR attempted to calculate the remainder with overflow
//~^ ERROR attempt to calculate the remainder with overflow
assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err());
//~^ ERROR attempted to calculate the remainder with overflow
//~^ ERROR attempt to calculate the remainder with overflow
assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err());
//~^ ERROR attempted to calculate the remainder with a divisor of zero
//~^ ERROR attempt to calculate the remainder with a divisor of zero
assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err());
//~^ ERROR attempted to calculate the remainder with a divisor of zero
//~^ ERROR attempt to calculate the remainder with a divisor of zero
assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err());
//~^ ERROR attempted to calculate the remainder with a divisor of zero
//~^ ERROR attempt to calculate the remainder with a divisor of zero
assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err());
//~^ ERROR attempted to calculate the remainder with a divisor of zero
//~^ ERROR attempt to calculate the remainder with a divisor of zero
assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err());
//~^ ERROR attempted to calculate the remainder with a divisor of zero
//~^ ERROR attempt to calculate the remainder with a divisor of zero
}
Loading