Adjust tests to more aggressive const err linting

This commit is contained in:
Oliver Schneider 2018-01-29 10:29:10 +01:00
parent 21554b96af
commit d57a109203
No known key found for this signature in database
GPG Key ID: A69F8D225B3AD7D9
5 changed files with 26 additions and 0 deletions

View File

@ -14,6 +14,7 @@
pub const A: i8 = -std::i8::MIN; //~ ERROR E0080
//~^ ERROR attempt to negate with overflow
//~| ERROR const_err
//~| ERROR const_err
pub const B: u8 = 200u8 + 200u8; //~ ERROR E0080
pub const C: u8 = 200u8 * 4; //~ ERROR E0080
pub const D: u8 = 42u8 - (42u8 + 1); //~ ERROR E0080

View File

@ -13,6 +13,7 @@
pub const A: i8 = -std::i8::MIN; //~ ERROR attempt to negate with overflow
//~^ ERROR E0080
//~| ERROR const_err
//~| ERROR const_err
pub const B: i8 = A;
//~^ ERROR E0080
pub const C: u8 = A as u8;

View File

@ -13,10 +13,12 @@ enum Test {
//~^ attempt to divide by zero
//~| ERROR constant evaluation error
//~| WARN constant evaluation error
//~| WARN constant evaluation error
RemZero = 1%0,
//~^ attempt to calculate the remainder with a divisor of zero
//~| ERROR constant evaluation error
//~| WARN constant evaluation error
//~| WARN constant evaluation error
}
fn main() {}

View File

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

View File

@ -13,6 +13,8 @@ enum Enum {
//~| shift left with overflow
Y = (1 / 0) //~ ERROR E0080
//~| const_err
//~| const_err
//~| const_err
//~| divide by zero
}