diff --git a/src/test/compile-fail/const-err-early.rs b/src/test/compile-fail/const-err-early.rs index 2e19de0a279..4a146d8de3c 100644 --- a/src/test/compile-fail/const-err-early.rs +++ b/src/test/compile-fail/const-err-early.rs @@ -12,7 +12,6 @@ #![deny(const_err)] 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 diff --git a/src/test/compile-fail/const-err-multi.rs b/src/test/compile-fail/const-err-multi.rs index 5fa31e05322..eb24a698419 100644 --- a/src/test/compile-fail/const-err-multi.rs +++ b/src/test/compile-fail/const-err-multi.rs @@ -10,7 +10,7 @@ #![deny(const_err)] -pub const A: i8 = -std::i8::MIN; //~ ERROR attempt to negate with overflow +pub const A: i8 = -std::i8::MIN; //~^ ERROR E0080 //~| ERROR const_err //~| ERROR const_err diff --git a/src/test/compile-fail/issue-8460-const.rs b/src/test/compile-fail/issue-8460-const.rs index e2cf88d5774..024aca2e66d 100644 --- a/src/test/compile-fail/issue-8460-const.rs +++ b/src/test/compile-fail/issue-8460-const.rs @@ -9,89 +9,110 @@ // except according to those terms. #![deny(const_err)] +//~^ NOTE lint level defined here use std::{isize, i8, i16, i32, i64}; use std::thread; fn main() { assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err()); - //~^ ERROR attempt to divide with overflow + //~^ NOTE attempt to divide with overflow + //~| NOTE attempted to do overflowing math //~| ERROR constant evaluation error //~| ERROR constant evaluation error assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err()); - //~^ ERROR attempt to divide with overflow + //~^ NOTE attempt to divide with overflow + //~| NOTE attempted to do overflowing math //~| ERROR constant evaluation error //~| ERROR constant evaluation error assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err()); - //~^ ERROR attempt to divide with overflow + //~^ NOTE attempt to divide with overflow + //~| NOTE attempted to do overflowing math //~| ERROR constant evaluation error //~| ERROR constant evaluation error assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err()); - //~^ ERROR attempt to divide with overflow + //~^ NOTE attempt to divide with overflow + //~| NOTE attempted to do overflowing math //~| ERROR constant evaluation error //~| ERROR constant evaluation error assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err()); - //~^ ERROR attempt to divide with overflow + //~^ NOTE attempt to divide with overflow + //~| NOTE attempted to do overflowing math //~| ERROR constant evaluation error //~| ERROR constant evaluation error assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); - //~^ ERROR attempt to divide by zero + //~^ NOTE attempt to divide by zero + //~| NOTE attempted to do overflowing math //~| ERROR constant evaluation error //~| ERROR constant evaluation error assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err()); - //~^ ERROR attempt to divide by zero + //~^ NOTE attempt to divide by zero + //~| NOTE attempted to do overflowing math //~| ERROR constant evaluation error //~| ERROR constant evaluation error assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err()); - //~^ ERROR attempt to divide by zero + //~^ NOTE attempt to divide by zero + //~| NOTE attempted to do overflowing math //~| ERROR constant evaluation error //~| ERROR constant evaluation error assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err()); - //~^ ERROR attempt to divide by zero + //~^ NOTE attempt to divide by zero + //~| NOTE attempted to do overflowing math //~| ERROR constant evaluation error //~| ERROR constant evaluation error assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err()); - //~^ ERROR attempt to divide by zero + //~^ NOTE attempt to divide by zero + //~| NOTE attempted to do overflowing math //~| 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 + //~^ NOTE attempt to calculate the remainder with overflow + //~| NOTE attempted to do overflowing math //~| 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 + //~^ NOTE attempt to calculate the remainder with overflow + //~| NOTE attempted to do overflowing math //~| 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 + //~^ NOTE attempt to calculate the remainder with overflow + //~| NOTE attempted to do overflowing math //~| 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 + //~^ NOTE attempt to calculate the remainder with overflow + //~| NOTE attempted to do overflowing math //~| 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 + //~^ NOTE attempt to calculate the remainder with overflow + //~| NOTE attempted to do overflowing math //~| 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 + //~^ NOTE attempt to calculate the remainder with a divisor of zero + //~| NOTE attempted to do overflowing math //~| 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 + //~^ NOTE attempt to calculate the remainder with a divisor of zero + //~| NOTE attempted to do overflowing math //~| 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 + //~^ NOTE attempt to calculate the remainder with a divisor of zero + //~| NOTE attempted to do overflowing math //~| 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 + //~^ NOTE attempt to calculate the remainder with a divisor of zero + //~| NOTE attempted to do overflowing math //~| 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 + //~^ NOTE attempt to calculate the remainder with a divisor of zero + //~| NOTE attempted to do overflowing math //~| ERROR constant evaluation error //~| ERROR constant evaluation error } diff --git a/src/test/compile-fail/lint-exceeding-bitshifts2.rs b/src/test/compile-fail/lint-exceeding-bitshifts2.rs index d95e1b370aa..0eab143fa49 100644 --- a/src/test/compile-fail/lint-exceeding-bitshifts2.rs +++ b/src/test/compile-fail/lint-exceeding-bitshifts2.rs @@ -8,13 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![deny(exceeding_bitshifts)] -#![allow(unused_variables, const_err)] +#![deny(exceeding_bitshifts, const_err)] +#![allow(unused_variables)] #![allow(dead_code)] fn main() { let n = 1u8 << (4+3); - let n = 1u8 << (4+4); //~ ERROR: bitshift exceeds the type's number of bits + let n = 1u8 << (4+4); //~ ERROR: const_err let n = 1i64 >> [63][0]; let n = 1i64 >> [64][0]; // should be linting, needs to wait for const propagation @@ -22,6 +22,6 @@ fn main() { const BITS: usize = 32; #[cfg(target_pointer_width = "64")] const BITS: usize = 64; - let n = 1_isize << BITS; //~ ERROR: bitshift exceeds the type's number of bits - let n = 1_usize << BITS; //~ ERROR: bitshift exceeds the type's number of bits + let n = 1_isize << BITS; //~ ERROR: const_err + let n = 1_usize << BITS; //~ ERROR: const_err }