From bd485223149e35c1c4e6b3ecf58653e38de4b6c9 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 15 Feb 2020 10:47:27 +0100 Subject: [PATCH] fix tests, and use variants to test debug and release builds together --- src/test/ui/consts/array-literal-index-oob.rs | 4 +- .../ui/consts/array-literal-index-oob.stderr | 16 +- ...st-err2.stderr => const-err2.debug.stderr} | 38 ++- src/test/ui/consts/const-err2.opt.stderr | 48 ++++ ...const-err2.opt_with_overflow_checks.stderr | 48 ++++ src/test/ui/consts/const-err2.rs | 23 +- src/test/ui/consts/const-err3.rs | 38 --- src/test/ui/consts/const-err3.stderr | 50 ---- .../index_out_of_bounds_propagated.rs | 2 +- .../index_out_of_bounds_propagated.stderr | 6 +- .../const-eval/promoted_errors.debug.stderr | 78 ++++++ .../const-eval/promoted_errors.opt.stderr | 72 ++++++ ...ted_errors.opt_with_overflow_checks.stderr | 78 ++++++ .../ui/consts/const-eval/promoted_errors.rs | 23 +- .../consts/const-eval/promoted_errors.stderr | 60 ----- .../ui/consts/const-eval/promoted_errors2.rs | 24 -- .../consts/const-eval/promoted_errors2.stderr | 66 ------ src/test/ui/consts/const-prop-ice.rs | 2 +- src/test/ui/consts/const-prop-ice.stderr | 6 +- src/test/ui/consts/const-prop-ice2.rs | 2 +- src/test/ui/consts/const-prop-ice2.stderr | 6 +- .../ui/issues/issue-8460-const.debug.stderr | 150 ++++++++++++ .../ui/issues/issue-8460-const.opt.stderr | 150 ++++++++++++ ...8460-const.opt_with_overflow_checks.stderr | 150 ++++++++++++ src/test/ui/issues/issue-8460-const.rs | 66 +++--- src/test/ui/issues/issue-8460-const.stderr | 224 ------------------ src/test/ui/issues/issue-8460-const2.rs | 58 ----- src/test/ui/issues/issue-8460-const2.stderr | 152 ------------ 28 files changed, 872 insertions(+), 768 deletions(-) rename src/test/ui/consts/{const-err2.stderr => const-err2.debug.stderr} (51%) create mode 100644 src/test/ui/consts/const-err2.opt.stderr create mode 100644 src/test/ui/consts/const-err2.opt_with_overflow_checks.stderr delete mode 100644 src/test/ui/consts/const-err3.rs delete mode 100644 src/test/ui/consts/const-err3.stderr create mode 100644 src/test/ui/consts/const-eval/promoted_errors.debug.stderr create mode 100644 src/test/ui/consts/const-eval/promoted_errors.opt.stderr create mode 100644 src/test/ui/consts/const-eval/promoted_errors.opt_with_overflow_checks.stderr delete mode 100644 src/test/ui/consts/const-eval/promoted_errors.stderr delete mode 100644 src/test/ui/consts/const-eval/promoted_errors2.rs delete mode 100644 src/test/ui/consts/const-eval/promoted_errors2.stderr create mode 100644 src/test/ui/issues/issue-8460-const.debug.stderr create mode 100644 src/test/ui/issues/issue-8460-const.opt.stderr create mode 100644 src/test/ui/issues/issue-8460-const.opt_with_overflow_checks.stderr delete mode 100644 src/test/ui/issues/issue-8460-const.stderr delete mode 100644 src/test/ui/issues/issue-8460-const2.rs delete mode 100644 src/test/ui/issues/issue-8460-const2.stderr diff --git a/src/test/ui/consts/array-literal-index-oob.rs b/src/test/ui/consts/array-literal-index-oob.rs index af63d1f75a77..978f23331012 100644 --- a/src/test/ui/consts/array-literal-index-oob.rs +++ b/src/test/ui/consts/array-literal-index-oob.rs @@ -1,11 +1,11 @@ // build-pass // ignore-pass (emit codegen-time warnings and verify that they are indeed warnings and not errors) -#![warn(const_err)] +#![warn(const_err, panic)] fn main() { &{ [1, 2, 3][4] }; - //~^ WARN index out of bounds + //~^ WARN operation will panic //~| WARN reaching this expression at runtime will panic or abort //~| WARN erroneous constant used [const_err] } diff --git a/src/test/ui/consts/array-literal-index-oob.stderr b/src/test/ui/consts/array-literal-index-oob.stderr index 59e116970150..605cd73db1f8 100644 --- a/src/test/ui/consts/array-literal-index-oob.stderr +++ b/src/test/ui/consts/array-literal-index-oob.stderr @@ -1,14 +1,14 @@ -warning: index out of bounds: the len is 3 but the index is 4 +warning: this operation will panic at runtime --> $DIR/array-literal-index-oob.rs:7:8 | LL | &{ [1, 2, 3][4] }; - | ^^^^^^^^^^^^ + | ^^^^^^^^^^^^ index out of bounds: the len is 3 but the index is 4 | note: the lint level is defined here - --> $DIR/array-literal-index-oob.rs:4:9 + --> $DIR/array-literal-index-oob.rs:4:20 | -LL | #![warn(const_err)] - | ^^^^^^^^^ +LL | #![warn(const_err, panic)] + | ^^^^^ warning: reaching this expression at runtime will panic or abort --> $DIR/array-literal-index-oob.rs:7:8 @@ -17,6 +17,12 @@ LL | &{ [1, 2, 3][4] }; | ---^^^^^^^^^^^^-- | | | indexing out of bounds: the len is 3 but the index is 4 + | +note: the lint level is defined here + --> $DIR/array-literal-index-oob.rs:4:9 + | +LL | #![warn(const_err, panic)] + | ^^^^^^^^^ warning: erroneous constant used --> $DIR/array-literal-index-oob.rs:7:5 diff --git a/src/test/ui/consts/const-err2.stderr b/src/test/ui/consts/const-err2.debug.stderr similarity index 51% rename from src/test/ui/consts/const-err2.stderr rename to src/test/ui/consts/const-err2.debug.stderr index f135bf0b06ca..226874c29da2 100644 --- a/src/test/ui/consts/const-err2.stderr +++ b/src/test/ui/consts/const-err2.debug.stderr @@ -1,50 +1,48 @@ -error: this expression will panic at runtime - --> $DIR/const-err2.rs:18:13 +error: this arithmetic operation will overflow + --> $DIR/const-err2.rs:19:13 | LL | let a = -std::i8::MIN; | ^^^^^^^^^^^^^ attempt to negate with overflow | -note: the lint level is defined here - --> $DIR/const-err2.rs:11:9 - | -LL | #![deny(const_err)] - | ^^^^^^^^^ + = note: `#[deny(overflow)]` on by default -error: this expression will panic at runtime - --> $DIR/const-err2.rs:20:18 +error: this arithmetic operation will overflow + --> $DIR/const-err2.rs:21:18 | LL | let a_i128 = -std::i128::MIN; | ^^^^^^^^^^^^^^^ attempt to negate with overflow -error: this expression will panic at runtime - --> $DIR/const-err2.rs:22:13 +error: this arithmetic operation will overflow + --> $DIR/const-err2.rs:23:13 | LL | let b = 200u8 + 200u8 + 200u8; | ^^^^^^^^^^^^^ attempt to add with overflow -error: this expression will panic at runtime - --> $DIR/const-err2.rs:24:18 +error: this arithmetic operation will overflow + --> $DIR/const-err2.rs:25:18 | LL | let b_i128 = std::i128::MIN - std::i128::MAX; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to subtract with overflow -error: this expression will panic at runtime - --> $DIR/const-err2.rs:26:13 +error: this arithmetic operation will overflow + --> $DIR/const-err2.rs:27:13 | LL | let c = 200u8 * 4; | ^^^^^^^^^ attempt to multiply with overflow -error: this expression will panic at runtime - --> $DIR/const-err2.rs:28:13 +error: this arithmetic operation will overflow + --> $DIR/const-err2.rs:29:13 | LL | let d = 42u8 - (42u8 + 1); | ^^^^^^^^^^^^^^^^^ attempt to subtract with overflow -error: index out of bounds: the len is 1 but the index is 1 - --> $DIR/const-err2.rs:30:14 +error: this operation will panic at runtime + --> $DIR/const-err2.rs:31:14 | LL | let _e = [5u8][1]; - | ^^^^^^^^ + | ^^^^^^^^ index out of bounds: the len is 1 but the index is 1 + | + = note: `#[deny(panic)]` on by default error: aborting due to 7 previous errors diff --git a/src/test/ui/consts/const-err2.opt.stderr b/src/test/ui/consts/const-err2.opt.stderr new file mode 100644 index 000000000000..226874c29da2 --- /dev/null +++ b/src/test/ui/consts/const-err2.opt.stderr @@ -0,0 +1,48 @@ +error: this arithmetic operation will overflow + --> $DIR/const-err2.rs:19:13 + | +LL | let a = -std::i8::MIN; + | ^^^^^^^^^^^^^ attempt to negate with overflow + | + = note: `#[deny(overflow)]` on by default + +error: this arithmetic operation will overflow + --> $DIR/const-err2.rs:21:18 + | +LL | let a_i128 = -std::i128::MIN; + | ^^^^^^^^^^^^^^^ attempt to negate with overflow + +error: this arithmetic operation will overflow + --> $DIR/const-err2.rs:23:13 + | +LL | let b = 200u8 + 200u8 + 200u8; + | ^^^^^^^^^^^^^ attempt to add with overflow + +error: this arithmetic operation will overflow + --> $DIR/const-err2.rs:25:18 + | +LL | let b_i128 = std::i128::MIN - std::i128::MAX; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to subtract with overflow + +error: this arithmetic operation will overflow + --> $DIR/const-err2.rs:27:13 + | +LL | let c = 200u8 * 4; + | ^^^^^^^^^ attempt to multiply with overflow + +error: this arithmetic operation will overflow + --> $DIR/const-err2.rs:29:13 + | +LL | let d = 42u8 - (42u8 + 1); + | ^^^^^^^^^^^^^^^^^ attempt to subtract with overflow + +error: this operation will panic at runtime + --> $DIR/const-err2.rs:31:14 + | +LL | let _e = [5u8][1]; + | ^^^^^^^^ index out of bounds: the len is 1 but the index is 1 + | + = note: `#[deny(panic)]` on by default + +error: aborting due to 7 previous errors + diff --git a/src/test/ui/consts/const-err2.opt_with_overflow_checks.stderr b/src/test/ui/consts/const-err2.opt_with_overflow_checks.stderr new file mode 100644 index 000000000000..226874c29da2 --- /dev/null +++ b/src/test/ui/consts/const-err2.opt_with_overflow_checks.stderr @@ -0,0 +1,48 @@ +error: this arithmetic operation will overflow + --> $DIR/const-err2.rs:19:13 + | +LL | let a = -std::i8::MIN; + | ^^^^^^^^^^^^^ attempt to negate with overflow + | + = note: `#[deny(overflow)]` on by default + +error: this arithmetic operation will overflow + --> $DIR/const-err2.rs:21:18 + | +LL | let a_i128 = -std::i128::MIN; + | ^^^^^^^^^^^^^^^ attempt to negate with overflow + +error: this arithmetic operation will overflow + --> $DIR/const-err2.rs:23:13 + | +LL | let b = 200u8 + 200u8 + 200u8; + | ^^^^^^^^^^^^^ attempt to add with overflow + +error: this arithmetic operation will overflow + --> $DIR/const-err2.rs:25:18 + | +LL | let b_i128 = std::i128::MIN - std::i128::MAX; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to subtract with overflow + +error: this arithmetic operation will overflow + --> $DIR/const-err2.rs:27:13 + | +LL | let c = 200u8 * 4; + | ^^^^^^^^^ attempt to multiply with overflow + +error: this arithmetic operation will overflow + --> $DIR/const-err2.rs:29:13 + | +LL | let d = 42u8 - (42u8 + 1); + | ^^^^^^^^^^^^^^^^^ attempt to subtract with overflow + +error: this operation will panic at runtime + --> $DIR/const-err2.rs:31:14 + | +LL | let _e = [5u8][1]; + | ^^^^^^^^ index out of bounds: the len is 1 but the index is 1 + | + = note: `#[deny(panic)]` on by default + +error: aborting due to 7 previous errors + diff --git a/src/test/ui/consts/const-err2.rs b/src/test/ui/consts/const-err2.rs index 7c5aaedda35f..6ef4e17df837 100644 --- a/src/test/ui/consts/const-err2.rs +++ b/src/test/ui/consts/const-err2.rs @@ -2,13 +2,14 @@ // optimized compilation and unoptimized compilation and thus would // lead to different lints being emitted +// revisions: debug opt opt_with_overflow_checks +//[debug]compile-flags: -C opt-level=0 +//[opt]compile-flags: -O +//[opt_with_overflow_checks]compile-flags: -C overflow-checks=on -O + // build-fail -// compile-flags: -O #![feature(rustc_attrs)] -#![allow(exceeding_bitshifts)] - -#![deny(const_err)] fn black_box(_: T) { unimplemented!() @@ -16,19 +17,19 @@ fn black_box(_: T) { fn main() { let a = -std::i8::MIN; - //~^ ERROR const_err + //~^ ERROR arithmetic operation will overflow let a_i128 = -std::i128::MIN; - //~^ ERROR const_err + //~^ ERROR arithmetic operation will overflow let b = 200u8 + 200u8 + 200u8; - //~^ ERROR const_err + //~^ ERROR arithmetic operation will overflow let b_i128 = std::i128::MIN - std::i128::MAX; - //~^ ERROR const_err + //~^ ERROR arithmetic operation will overflow let c = 200u8 * 4; - //~^ ERROR const_err + //~^ ERROR arithmetic operation will overflow let d = 42u8 - (42u8 + 1); - //~^ ERROR const_err + //~^ ERROR arithmetic operation will overflow let _e = [5u8][1]; - //~^ ERROR const_err + //~^ ERROR operation will panic black_box(a); black_box(a_i128); black_box(b); diff --git a/src/test/ui/consts/const-err3.rs b/src/test/ui/consts/const-err3.rs deleted file mode 100644 index 43aba4a8b012..000000000000 --- a/src/test/ui/consts/const-err3.rs +++ /dev/null @@ -1,38 +0,0 @@ -// needed because negating int::MIN will behave differently between -// optimized compilation and unoptimized compilation and thus would -// lead to different lints being emitted - -// build-fail -// compile-flags: -C overflow-checks=on -O - -#![feature(rustc_attrs)] -#![allow(exceeding_bitshifts)] - -#![deny(const_err)] - -fn black_box(_: T) { - unimplemented!() -} - -fn main() { - let a = -std::i8::MIN; - //~^ ERROR const_err - let a_i128 = -std::i128::MIN; - //~^ ERROR const_err - let b = 200u8 + 200u8 + 200u8; - //~^ ERROR const_err - let b_i128 = std::i128::MIN - std::i128::MAX; - //~^ ERROR const_err - let c = 200u8 * 4; - //~^ ERROR const_err - let d = 42u8 - (42u8 + 1); - //~^ ERROR const_err - let _e = [5u8][1]; - //~^ ERROR const_err - black_box(a); - black_box(a_i128); - black_box(b); - black_box(b_i128); - black_box(c); - black_box(d); -} diff --git a/src/test/ui/consts/const-err3.stderr b/src/test/ui/consts/const-err3.stderr deleted file mode 100644 index 05f64b87fcce..000000000000 --- a/src/test/ui/consts/const-err3.stderr +++ /dev/null @@ -1,50 +0,0 @@ -error: attempt to negate with overflow - --> $DIR/const-err3.rs:18:13 - | -LL | let a = -std::i8::MIN; - | ^^^^^^^^^^^^^ - | -note: the lint level is defined here - --> $DIR/const-err3.rs:11:9 - | -LL | #![deny(const_err)] - | ^^^^^^^^^ - -error: attempt to negate with overflow - --> $DIR/const-err3.rs:20:18 - | -LL | let a_i128 = -std::i128::MIN; - | ^^^^^^^^^^^^^^^ - -error: attempt to add with overflow - --> $DIR/const-err3.rs:22:13 - | -LL | let b = 200u8 + 200u8 + 200u8; - | ^^^^^^^^^^^^^ - -error: attempt to subtract with overflow - --> $DIR/const-err3.rs:24:18 - | -LL | let b_i128 = std::i128::MIN - std::i128::MAX; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: attempt to multiply with overflow - --> $DIR/const-err3.rs:26:13 - | -LL | let c = 200u8 * 4; - | ^^^^^^^^^ - -error: attempt to subtract with overflow - --> $DIR/const-err3.rs:28:13 - | -LL | let d = 42u8 - (42u8 + 1); - | ^^^^^^^^^^^^^^^^^ - -error: index out of bounds: the len is 1 but the index is 1 - --> $DIR/const-err3.rs:30:14 - | -LL | let _e = [5u8][1]; - | ^^^^^^^^ - -error: aborting due to 7 previous errors - diff --git a/src/test/ui/consts/const-eval/index_out_of_bounds_propagated.rs b/src/test/ui/consts/const-eval/index_out_of_bounds_propagated.rs index 6d6bb94d4dff..608e6e112a10 100644 --- a/src/test/ui/consts/const-eval/index_out_of_bounds_propagated.rs +++ b/src/test/ui/consts/const-eval/index_out_of_bounds_propagated.rs @@ -2,5 +2,5 @@ fn main() { let array = [std::env::args().len()]; - array[1]; //~ ERROR index out of bounds + array[1]; //~ ERROR operation will panic } diff --git a/src/test/ui/consts/const-eval/index_out_of_bounds_propagated.stderr b/src/test/ui/consts/const-eval/index_out_of_bounds_propagated.stderr index 9519ccd3c248..5da802d30f5a 100644 --- a/src/test/ui/consts/const-eval/index_out_of_bounds_propagated.stderr +++ b/src/test/ui/consts/const-eval/index_out_of_bounds_propagated.stderr @@ -1,10 +1,10 @@ -error: index out of bounds: the len is 1 but the index is 1 +error: this operation will panic at runtime --> $DIR/index_out_of_bounds_propagated.rs:5:5 | LL | array[1]; - | ^^^^^^^^ + | ^^^^^^^^ index out of bounds: the len is 1 but the index is 1 | - = note: `#[deny(const_err)]` on by default + = note: `#[deny(panic)]` on by default error: aborting due to previous error diff --git a/src/test/ui/consts/const-eval/promoted_errors.debug.stderr b/src/test/ui/consts/const-eval/promoted_errors.debug.stderr new file mode 100644 index 000000000000..1ed60c1f96e4 --- /dev/null +++ b/src/test/ui/consts/const-eval/promoted_errors.debug.stderr @@ -0,0 +1,78 @@ +warning: this arithmetic operation will overflow + --> $DIR/promoted_errors.rs:12:20 + | +LL | println!("{}", 0u32 - 1); + | ^^^^^^^^ attempt to subtract with overflow + | +note: the lint level is defined here + --> $DIR/promoted_errors.rs:9:20 + | +LL | #![warn(const_err, overflow, panic)] + | ^^^^^^^^ + +warning: this arithmetic operation will overflow + --> $DIR/promoted_errors.rs:14:14 + | +LL | let _x = 0u32 - 1; + | ^^^^^^^^ attempt to subtract with overflow + +warning: this operation will panic at runtime + --> $DIR/promoted_errors.rs:16:20 + | +LL | println!("{}", 1 / (1 - 1)); + | ^^^^^^^^^^^ attempt to divide by zero + | +note: the lint level is defined here + --> $DIR/promoted_errors.rs:9:30 + | +LL | #![warn(const_err, overflow, panic)] + | ^^^^^ + +warning: reaching this expression at runtime will panic or abort + --> $DIR/promoted_errors.rs:16:20 + | +LL | println!("{}", 1 / (1 - 1)); + | ^^^^^^^^^^^ dividing by zero + | +note: the lint level is defined here + --> $DIR/promoted_errors.rs:9:9 + | +LL | #![warn(const_err, overflow, panic)] + | ^^^^^^^^^ + +warning: erroneous constant used + --> $DIR/promoted_errors.rs:16:20 + | +LL | println!("{}", 1 / (1 - 1)); + | ^^^^^^^^^^^ referenced constant has errors + +warning: this operation will panic at runtime + --> $DIR/promoted_errors.rs:20:14 + | +LL | let _x = 1 / (1 - 1); + | ^^^^^^^^^^^ attempt to divide by zero + +warning: this operation will panic at runtime + --> $DIR/promoted_errors.rs:22:20 + | +LL | println!("{}", 1 / (false as u32)); + | ^^^^^^^^^^^^^^^^^^ attempt to divide by zero + +warning: reaching this expression at runtime will panic or abort + --> $DIR/promoted_errors.rs:22:20 + | +LL | println!("{}", 1 / (false as u32)); + | ^^^^^^^^^^^^^^^^^^ dividing by zero + +warning: erroneous constant used + --> $DIR/promoted_errors.rs:22:20 + | +LL | println!("{}", 1 / (false as u32)); + | ^^^^^^^^^^^^^^^^^^ referenced constant has errors + +warning: this operation will panic at runtime + --> $DIR/promoted_errors.rs:26:14 + | +LL | let _x = 1 / (false as u32); + | ^^^^^^^^^^^^^^^^^^ attempt to divide by zero + diff --git a/src/test/ui/consts/const-eval/promoted_errors.opt.stderr b/src/test/ui/consts/const-eval/promoted_errors.opt.stderr new file mode 100644 index 000000000000..8f21ce537155 --- /dev/null +++ b/src/test/ui/consts/const-eval/promoted_errors.opt.stderr @@ -0,0 +1,72 @@ +warning: this arithmetic operation will overflow + --> $DIR/promoted_errors.rs:14:14 + | +LL | let _x = 0u32 - 1; + | ^^^^^^^^ attempt to subtract with overflow + | +note: the lint level is defined here + --> $DIR/promoted_errors.rs:9:20 + | +LL | #![warn(const_err, overflow, panic)] + | ^^^^^^^^ + +warning: this operation will panic at runtime + --> $DIR/promoted_errors.rs:16:20 + | +LL | println!("{}", 1 / (1 - 1)); + | ^^^^^^^^^^^ attempt to divide by zero + | +note: the lint level is defined here + --> $DIR/promoted_errors.rs:9:30 + | +LL | #![warn(const_err, overflow, panic)] + | ^^^^^ + +warning: reaching this expression at runtime will panic or abort + --> $DIR/promoted_errors.rs:16:20 + | +LL | println!("{}", 1 / (1 - 1)); + | ^^^^^^^^^^^ dividing by zero + | +note: the lint level is defined here + --> $DIR/promoted_errors.rs:9:9 + | +LL | #![warn(const_err, overflow, panic)] + | ^^^^^^^^^ + +warning: erroneous constant used + --> $DIR/promoted_errors.rs:16:20 + | +LL | println!("{}", 1 / (1 - 1)); + | ^^^^^^^^^^^ referenced constant has errors + +warning: this operation will panic at runtime + --> $DIR/promoted_errors.rs:20:14 + | +LL | let _x = 1 / (1 - 1); + | ^^^^^^^^^^^ attempt to divide by zero + +warning: this operation will panic at runtime + --> $DIR/promoted_errors.rs:22:20 + | +LL | println!("{}", 1 / (false as u32)); + | ^^^^^^^^^^^^^^^^^^ attempt to divide by zero + +warning: reaching this expression at runtime will panic or abort + --> $DIR/promoted_errors.rs:22:20 + | +LL | println!("{}", 1 / (false as u32)); + | ^^^^^^^^^^^^^^^^^^ dividing by zero + +warning: erroneous constant used + --> $DIR/promoted_errors.rs:22:20 + | +LL | println!("{}", 1 / (false as u32)); + | ^^^^^^^^^^^^^^^^^^ referenced constant has errors + +warning: this operation will panic at runtime + --> $DIR/promoted_errors.rs:26:14 + | +LL | let _x = 1 / (false as u32); + | ^^^^^^^^^^^^^^^^^^ attempt to divide by zero + diff --git a/src/test/ui/consts/const-eval/promoted_errors.opt_with_overflow_checks.stderr b/src/test/ui/consts/const-eval/promoted_errors.opt_with_overflow_checks.stderr new file mode 100644 index 000000000000..1ed60c1f96e4 --- /dev/null +++ b/src/test/ui/consts/const-eval/promoted_errors.opt_with_overflow_checks.stderr @@ -0,0 +1,78 @@ +warning: this arithmetic operation will overflow + --> $DIR/promoted_errors.rs:12:20 + | +LL | println!("{}", 0u32 - 1); + | ^^^^^^^^ attempt to subtract with overflow + | +note: the lint level is defined here + --> $DIR/promoted_errors.rs:9:20 + | +LL | #![warn(const_err, overflow, panic)] + | ^^^^^^^^ + +warning: this arithmetic operation will overflow + --> $DIR/promoted_errors.rs:14:14 + | +LL | let _x = 0u32 - 1; + | ^^^^^^^^ attempt to subtract with overflow + +warning: this operation will panic at runtime + --> $DIR/promoted_errors.rs:16:20 + | +LL | println!("{}", 1 / (1 - 1)); + | ^^^^^^^^^^^ attempt to divide by zero + | +note: the lint level is defined here + --> $DIR/promoted_errors.rs:9:30 + | +LL | #![warn(const_err, overflow, panic)] + | ^^^^^ + +warning: reaching this expression at runtime will panic or abort + --> $DIR/promoted_errors.rs:16:20 + | +LL | println!("{}", 1 / (1 - 1)); + | ^^^^^^^^^^^ dividing by zero + | +note: the lint level is defined here + --> $DIR/promoted_errors.rs:9:9 + | +LL | #![warn(const_err, overflow, panic)] + | ^^^^^^^^^ + +warning: erroneous constant used + --> $DIR/promoted_errors.rs:16:20 + | +LL | println!("{}", 1 / (1 - 1)); + | ^^^^^^^^^^^ referenced constant has errors + +warning: this operation will panic at runtime + --> $DIR/promoted_errors.rs:20:14 + | +LL | let _x = 1 / (1 - 1); + | ^^^^^^^^^^^ attempt to divide by zero + +warning: this operation will panic at runtime + --> $DIR/promoted_errors.rs:22:20 + | +LL | println!("{}", 1 / (false as u32)); + | ^^^^^^^^^^^^^^^^^^ attempt to divide by zero + +warning: reaching this expression at runtime will panic or abort + --> $DIR/promoted_errors.rs:22:20 + | +LL | println!("{}", 1 / (false as u32)); + | ^^^^^^^^^^^^^^^^^^ dividing by zero + +warning: erroneous constant used + --> $DIR/promoted_errors.rs:22:20 + | +LL | println!("{}", 1 / (false as u32)); + | ^^^^^^^^^^^^^^^^^^ referenced constant has errors + +warning: this operation will panic at runtime + --> $DIR/promoted_errors.rs:26:14 + | +LL | let _x = 1 / (false as u32); + | ^^^^^^^^^^^^^^^^^^ attempt to divide by zero + diff --git a/src/test/ui/consts/const-eval/promoted_errors.rs b/src/test/ui/consts/const-eval/promoted_errors.rs index 22f863fb15ac..5a4c7a66bf53 100644 --- a/src/test/ui/consts/const-eval/promoted_errors.rs +++ b/src/test/ui/consts/const-eval/promoted_errors.rs @@ -1,23 +1,28 @@ +// revisions: debug opt opt_with_overflow_checks +//[debug]compile-flags: -C opt-level=0 +//[opt]compile-flags: -O +//[opt_with_overflow_checks]compile-flags: -C overflow-checks=on -O + // build-pass // ignore-pass (emit codegen-time warnings and verify that they are indeed warnings and not errors) -// compile-flags: -O -#![warn(const_err)] +#![warn(const_err, overflow, panic)] fn main() { println!("{}", 0u32 - 1); + //[opt_with_overflow_checks,debug]~^ WARN [overflow] let _x = 0u32 - 1; - //~^ WARN const_err + //~^ WARN [overflow] println!("{}", 1 / (1 - 1)); - //~^ WARN attempt to divide by zero [const_err] - //~| WARN const_err + //~^ WARN [panic] + //~| WARN panic or abort [const_err] //~| WARN erroneous constant used [const_err] let _x = 1 / (1 - 1); - //~^ WARN const_err + //~^ WARN [panic] println!("{}", 1 / (false as u32)); - //~^ WARN attempt to divide by zero [const_err] - //~| WARN const_err + //~^ WARN [panic] + //~| WARN panic or abort [const_err] //~| WARN erroneous constant used [const_err] let _x = 1 / (false as u32); - //~^ WARN const_err + //~^ WARN [panic] } diff --git a/src/test/ui/consts/const-eval/promoted_errors.stderr b/src/test/ui/consts/const-eval/promoted_errors.stderr deleted file mode 100644 index 08ae5c7a32b6..000000000000 --- a/src/test/ui/consts/const-eval/promoted_errors.stderr +++ /dev/null @@ -1,60 +0,0 @@ -warning: this expression will panic at runtime - --> $DIR/promoted_errors.rs:9:14 - | -LL | let _x = 0u32 - 1; - | ^^^^^^^^ attempt to subtract with overflow - | -note: the lint level is defined here - --> $DIR/promoted_errors.rs:5:9 - | -LL | #![warn(const_err)] - | ^^^^^^^^^ - -warning: attempt to divide by zero - --> $DIR/promoted_errors.rs:11:20 - | -LL | println!("{}", 1 / (1 - 1)); - | ^^^^^^^^^^^ - -warning: reaching this expression at runtime will panic or abort - --> $DIR/promoted_errors.rs:11:20 - | -LL | println!("{}", 1 / (1 - 1)); - | ^^^^^^^^^^^ dividing by zero - -warning: erroneous constant used - --> $DIR/promoted_errors.rs:11:20 - | -LL | println!("{}", 1 / (1 - 1)); - | ^^^^^^^^^^^ referenced constant has errors - -warning: attempt to divide by zero - --> $DIR/promoted_errors.rs:15:14 - | -LL | let _x = 1 / (1 - 1); - | ^^^^^^^^^^^ - -warning: attempt to divide by zero - --> $DIR/promoted_errors.rs:17:20 - | -LL | println!("{}", 1 / (false as u32)); - | ^^^^^^^^^^^^^^^^^^ - -warning: reaching this expression at runtime will panic or abort - --> $DIR/promoted_errors.rs:17:20 - | -LL | println!("{}", 1 / (false as u32)); - | ^^^^^^^^^^^^^^^^^^ dividing by zero - -warning: erroneous constant used - --> $DIR/promoted_errors.rs:17:20 - | -LL | println!("{}", 1 / (false as u32)); - | ^^^^^^^^^^^^^^^^^^ referenced constant has errors - -warning: attempt to divide by zero - --> $DIR/promoted_errors.rs:21:14 - | -LL | let _x = 1 / (false as u32); - | ^^^^^^^^^^^^^^^^^^ - diff --git a/src/test/ui/consts/const-eval/promoted_errors2.rs b/src/test/ui/consts/const-eval/promoted_errors2.rs deleted file mode 100644 index 62c77f76d906..000000000000 --- a/src/test/ui/consts/const-eval/promoted_errors2.rs +++ /dev/null @@ -1,24 +0,0 @@ -// build-pass -// ignore-pass (emit codegen-time warnings and verify that they are indeed warnings and not errors) -// compile-flags: -C overflow-checks=on -O - -#![warn(const_err)] - -fn main() { - println!("{}", 0u32 - 1); - //~^ WARN attempt to subtract with overflow - let _x = 0u32 - 1; - //~^ WARN attempt to subtract with overflow - println!("{}", 1 / (1 - 1)); - //~^ WARN attempt to divide by zero [const_err] - //~| WARN const_err - //~| WARN erroneous constant used [const_err] - let _x = 1 / (1 - 1); - //~^ WARN const_err - println!("{}", 1 / (false as u32)); - //~^ WARN attempt to divide by zero [const_err] - //~| WARN const_err - //~| WARN erroneous constant used [const_err] - let _x = 1 / (false as u32); - //~^ WARN const_err -} diff --git a/src/test/ui/consts/const-eval/promoted_errors2.stderr b/src/test/ui/consts/const-eval/promoted_errors2.stderr deleted file mode 100644 index d1a9cb958e15..000000000000 --- a/src/test/ui/consts/const-eval/promoted_errors2.stderr +++ /dev/null @@ -1,66 +0,0 @@ -warning: attempt to subtract with overflow - --> $DIR/promoted_errors2.rs:8:20 - | -LL | println!("{}", 0u32 - 1); - | ^^^^^^^^ - | -note: the lint level is defined here - --> $DIR/promoted_errors2.rs:5:9 - | -LL | #![warn(const_err)] - | ^^^^^^^^^ - -warning: attempt to subtract with overflow - --> $DIR/promoted_errors2.rs:10:14 - | -LL | let _x = 0u32 - 1; - | ^^^^^^^^ - -warning: attempt to divide by zero - --> $DIR/promoted_errors2.rs:12:20 - | -LL | println!("{}", 1 / (1 - 1)); - | ^^^^^^^^^^^ - -warning: reaching this expression at runtime will panic or abort - --> $DIR/promoted_errors2.rs:12:20 - | -LL | println!("{}", 1 / (1 - 1)); - | ^^^^^^^^^^^ dividing by zero - -warning: erroneous constant used - --> $DIR/promoted_errors2.rs:12:20 - | -LL | println!("{}", 1 / (1 - 1)); - | ^^^^^^^^^^^ referenced constant has errors - -warning: attempt to divide by zero - --> $DIR/promoted_errors2.rs:16:14 - | -LL | let _x = 1 / (1 - 1); - | ^^^^^^^^^^^ - -warning: attempt to divide by zero - --> $DIR/promoted_errors2.rs:18:20 - | -LL | println!("{}", 1 / (false as u32)); - | ^^^^^^^^^^^^^^^^^^ - -warning: reaching this expression at runtime will panic or abort - --> $DIR/promoted_errors2.rs:18:20 - | -LL | println!("{}", 1 / (false as u32)); - | ^^^^^^^^^^^^^^^^^^ dividing by zero - -warning: erroneous constant used - --> $DIR/promoted_errors2.rs:18:20 - | -LL | println!("{}", 1 / (false as u32)); - | ^^^^^^^^^^^^^^^^^^ referenced constant has errors - -warning: attempt to divide by zero - --> $DIR/promoted_errors2.rs:22:14 - | -LL | let _x = 1 / (false as u32); - | ^^^^^^^^^^^^^^^^^^ - diff --git a/src/test/ui/consts/const-prop-ice.rs b/src/test/ui/consts/const-prop-ice.rs index 8682d2ee9015..5bffe0206294 100644 --- a/src/test/ui/consts/const-prop-ice.rs +++ b/src/test/ui/consts/const-prop-ice.rs @@ -1,5 +1,5 @@ // build-fail fn main() { - [0; 3][3u64 as usize]; //~ ERROR the len is 3 but the index is 3 + [0; 3][3u64 as usize]; //~ ERROR this operation will panic at runtime } diff --git a/src/test/ui/consts/const-prop-ice.stderr b/src/test/ui/consts/const-prop-ice.stderr index 65502a4ff71e..855b9e6b64bb 100644 --- a/src/test/ui/consts/const-prop-ice.stderr +++ b/src/test/ui/consts/const-prop-ice.stderr @@ -1,10 +1,10 @@ -error: index out of bounds: the len is 3 but the index is 3 +error: this operation will panic at runtime --> $DIR/const-prop-ice.rs:4:5 | LL | [0; 3][3u64 as usize]; - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^ index out of bounds: the len is 3 but the index is 3 | - = note: `#[deny(const_err)]` on by default + = note: `#[deny(panic)]` on by default error: aborting due to previous error diff --git a/src/test/ui/consts/const-prop-ice2.rs b/src/test/ui/consts/const-prop-ice2.rs index 6a73483026f7..d533e394c06f 100644 --- a/src/test/ui/consts/const-prop-ice2.rs +++ b/src/test/ui/consts/const-prop-ice2.rs @@ -3,5 +3,5 @@ fn main() { enum Enum { One=1 } let xs=[0;1 as usize]; - println!("{}", xs[Enum::One as usize]); //~ ERROR the len is 1 but the index is 1 + println!("{}", xs[Enum::One as usize]); //~ ERROR this operation will panic at runtime } diff --git a/src/test/ui/consts/const-prop-ice2.stderr b/src/test/ui/consts/const-prop-ice2.stderr index cbb8fde80f95..07faa39edc24 100644 --- a/src/test/ui/consts/const-prop-ice2.stderr +++ b/src/test/ui/consts/const-prop-ice2.stderr @@ -1,10 +1,10 @@ -error: index out of bounds: the len is 1 but the index is 1 +error: this operation will panic at runtime --> $DIR/const-prop-ice2.rs:6:20 | LL | println!("{}", xs[Enum::One as usize]); - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^ index out of bounds: the len is 1 but the index is 1 | - = note: `#[deny(const_err)]` on by default + = note: `#[deny(panic)]` on by default error: aborting due to previous error diff --git a/src/test/ui/issues/issue-8460-const.debug.stderr b/src/test/ui/issues/issue-8460-const.debug.stderr new file mode 100644 index 000000000000..33d846e3e910 --- /dev/null +++ b/src/test/ui/issues/issue-8460-const.debug.stderr @@ -0,0 +1,150 @@ +error: this arithmetic operation will overflow + --> $DIR/issue-8460-const.rs:14:36 + | +LL | assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err()); + | ^^^^^^^^^^^^^^^ attempt to divide with overflow + | + = note: `#[deny(overflow)]` on by default + +error: this arithmetic operation will overflow + --> $DIR/issue-8460-const.rs:16:36 + | +LL | assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err()); + | ^^^^^^^^^^^^ attempt to divide with overflow + +error: this arithmetic operation will overflow + --> $DIR/issue-8460-const.rs:18:36 + | +LL | assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err()); + | ^^^^^^^^^^^^^ attempt to divide with overflow + +error: this arithmetic operation will overflow + --> $DIR/issue-8460-const.rs:20:36 + | +LL | assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err()); + | ^^^^^^^^^^^^^ attempt to divide with overflow + +error: this arithmetic operation will overflow + --> $DIR/issue-8460-const.rs:22:36 + | +LL | assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err()); + | ^^^^^^^^^^^^^ attempt to divide with overflow + +error: this arithmetic operation will overflow + --> $DIR/issue-8460-const.rs:24:36 + | +LL | assert!(thread::spawn(move|| { i128::MIN / -1; }).join().is_err()); + | ^^^^^^^^^^^^^^ attempt to divide with overflow + +error: this operation will panic at runtime + --> $DIR/issue-8460-const.rs:26:36 + | +LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); + | ^^^^^^^^^^ attempt to divide by zero + | + = note: `#[deny(panic)]` on by default + +error: this operation will panic at runtime + --> $DIR/issue-8460-const.rs:28:36 + | +LL | assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err()); + | ^^^^^^^ attempt to divide by zero + +error: this operation will panic at runtime + --> $DIR/issue-8460-const.rs:30:36 + | +LL | assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err()); + | ^^^^^^^^ attempt to divide by zero + +error: this operation will panic at runtime + --> $DIR/issue-8460-const.rs:32:36 + | +LL | assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err()); + | ^^^^^^^^ attempt to divide by zero + +error: this operation will panic at runtime + --> $DIR/issue-8460-const.rs:34:36 + | +LL | assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err()); + | ^^^^^^^^ attempt to divide by zero + +error: this operation will panic at runtime + --> $DIR/issue-8460-const.rs:36:36 + | +LL | assert!(thread::spawn(move|| { 1i128 / 0; }).join().is_err()); + | ^^^^^^^^^ attempt to divide by zero + +error: this arithmetic operation will overflow + --> $DIR/issue-8460-const.rs:38:36 + | +LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err()); + | ^^^^^^^^^^^^^^^ attempt to calculate the remainder with overflow + +error: this arithmetic operation will overflow + --> $DIR/issue-8460-const.rs:40:36 + | +LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err()); + | ^^^^^^^^^^^^ attempt to calculate the remainder with overflow + +error: this arithmetic operation will overflow + --> $DIR/issue-8460-const.rs:42:36 + | +LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err()); + | ^^^^^^^^^^^^^ attempt to calculate the remainder with overflow + +error: this arithmetic operation will overflow + --> $DIR/issue-8460-const.rs:44:36 + | +LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err()); + | ^^^^^^^^^^^^^ attempt to calculate the remainder with overflow + +error: this arithmetic operation will overflow + --> $DIR/issue-8460-const.rs:46:36 + | +LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err()); + | ^^^^^^^^^^^^^ attempt to calculate the remainder with overflow + +error: this arithmetic operation will overflow + --> $DIR/issue-8460-const.rs:48:36 + | +LL | assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err()); + | ^^^^^^^^^^^^^^ attempt to calculate the remainder with overflow + +error: this operation will panic at runtime + --> $DIR/issue-8460-const.rs:50:36 + | +LL | assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err()); + | ^^^^^^^^^^ attempt to calculate the remainder with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/issue-8460-const.rs:52:36 + | +LL | assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err()); + | ^^^^^^^ attempt to calculate the remainder with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/issue-8460-const.rs:54:36 + | +LL | assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err()); + | ^^^^^^^^ attempt to calculate the remainder with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/issue-8460-const.rs:56:36 + | +LL | assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err()); + | ^^^^^^^^ attempt to calculate the remainder with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/issue-8460-const.rs:58:36 + | +LL | assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err()); + | ^^^^^^^^ attempt to calculate the remainder with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/issue-8460-const.rs:60:36 + | +LL | assert!(thread::spawn(move|| { 1i128 % 0; }).join().is_err()); + | ^^^^^^^^^ attempt to calculate the remainder with a divisor of zero + +error: aborting due to 24 previous errors + diff --git a/src/test/ui/issues/issue-8460-const.opt.stderr b/src/test/ui/issues/issue-8460-const.opt.stderr new file mode 100644 index 000000000000..33d846e3e910 --- /dev/null +++ b/src/test/ui/issues/issue-8460-const.opt.stderr @@ -0,0 +1,150 @@ +error: this arithmetic operation will overflow + --> $DIR/issue-8460-const.rs:14:36 + | +LL | assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err()); + | ^^^^^^^^^^^^^^^ attempt to divide with overflow + | + = note: `#[deny(overflow)]` on by default + +error: this arithmetic operation will overflow + --> $DIR/issue-8460-const.rs:16:36 + | +LL | assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err()); + | ^^^^^^^^^^^^ attempt to divide with overflow + +error: this arithmetic operation will overflow + --> $DIR/issue-8460-const.rs:18:36 + | +LL | assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err()); + | ^^^^^^^^^^^^^ attempt to divide with overflow + +error: this arithmetic operation will overflow + --> $DIR/issue-8460-const.rs:20:36 + | +LL | assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err()); + | ^^^^^^^^^^^^^ attempt to divide with overflow + +error: this arithmetic operation will overflow + --> $DIR/issue-8460-const.rs:22:36 + | +LL | assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err()); + | ^^^^^^^^^^^^^ attempt to divide with overflow + +error: this arithmetic operation will overflow + --> $DIR/issue-8460-const.rs:24:36 + | +LL | assert!(thread::spawn(move|| { i128::MIN / -1; }).join().is_err()); + | ^^^^^^^^^^^^^^ attempt to divide with overflow + +error: this operation will panic at runtime + --> $DIR/issue-8460-const.rs:26:36 + | +LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); + | ^^^^^^^^^^ attempt to divide by zero + | + = note: `#[deny(panic)]` on by default + +error: this operation will panic at runtime + --> $DIR/issue-8460-const.rs:28:36 + | +LL | assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err()); + | ^^^^^^^ attempt to divide by zero + +error: this operation will panic at runtime + --> $DIR/issue-8460-const.rs:30:36 + | +LL | assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err()); + | ^^^^^^^^ attempt to divide by zero + +error: this operation will panic at runtime + --> $DIR/issue-8460-const.rs:32:36 + | +LL | assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err()); + | ^^^^^^^^ attempt to divide by zero + +error: this operation will panic at runtime + --> $DIR/issue-8460-const.rs:34:36 + | +LL | assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err()); + | ^^^^^^^^ attempt to divide by zero + +error: this operation will panic at runtime + --> $DIR/issue-8460-const.rs:36:36 + | +LL | assert!(thread::spawn(move|| { 1i128 / 0; }).join().is_err()); + | ^^^^^^^^^ attempt to divide by zero + +error: this arithmetic operation will overflow + --> $DIR/issue-8460-const.rs:38:36 + | +LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err()); + | ^^^^^^^^^^^^^^^ attempt to calculate the remainder with overflow + +error: this arithmetic operation will overflow + --> $DIR/issue-8460-const.rs:40:36 + | +LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err()); + | ^^^^^^^^^^^^ attempt to calculate the remainder with overflow + +error: this arithmetic operation will overflow + --> $DIR/issue-8460-const.rs:42:36 + | +LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err()); + | ^^^^^^^^^^^^^ attempt to calculate the remainder with overflow + +error: this arithmetic operation will overflow + --> $DIR/issue-8460-const.rs:44:36 + | +LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err()); + | ^^^^^^^^^^^^^ attempt to calculate the remainder with overflow + +error: this arithmetic operation will overflow + --> $DIR/issue-8460-const.rs:46:36 + | +LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err()); + | ^^^^^^^^^^^^^ attempt to calculate the remainder with overflow + +error: this arithmetic operation will overflow + --> $DIR/issue-8460-const.rs:48:36 + | +LL | assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err()); + | ^^^^^^^^^^^^^^ attempt to calculate the remainder with overflow + +error: this operation will panic at runtime + --> $DIR/issue-8460-const.rs:50:36 + | +LL | assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err()); + | ^^^^^^^^^^ attempt to calculate the remainder with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/issue-8460-const.rs:52:36 + | +LL | assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err()); + | ^^^^^^^ attempt to calculate the remainder with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/issue-8460-const.rs:54:36 + | +LL | assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err()); + | ^^^^^^^^ attempt to calculate the remainder with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/issue-8460-const.rs:56:36 + | +LL | assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err()); + | ^^^^^^^^ attempt to calculate the remainder with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/issue-8460-const.rs:58:36 + | +LL | assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err()); + | ^^^^^^^^ attempt to calculate the remainder with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/issue-8460-const.rs:60:36 + | +LL | assert!(thread::spawn(move|| { 1i128 % 0; }).join().is_err()); + | ^^^^^^^^^ attempt to calculate the remainder with a divisor of zero + +error: aborting due to 24 previous errors + diff --git a/src/test/ui/issues/issue-8460-const.opt_with_overflow_checks.stderr b/src/test/ui/issues/issue-8460-const.opt_with_overflow_checks.stderr new file mode 100644 index 000000000000..33d846e3e910 --- /dev/null +++ b/src/test/ui/issues/issue-8460-const.opt_with_overflow_checks.stderr @@ -0,0 +1,150 @@ +error: this arithmetic operation will overflow + --> $DIR/issue-8460-const.rs:14:36 + | +LL | assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err()); + | ^^^^^^^^^^^^^^^ attempt to divide with overflow + | + = note: `#[deny(overflow)]` on by default + +error: this arithmetic operation will overflow + --> $DIR/issue-8460-const.rs:16:36 + | +LL | assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err()); + | ^^^^^^^^^^^^ attempt to divide with overflow + +error: this arithmetic operation will overflow + --> $DIR/issue-8460-const.rs:18:36 + | +LL | assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err()); + | ^^^^^^^^^^^^^ attempt to divide with overflow + +error: this arithmetic operation will overflow + --> $DIR/issue-8460-const.rs:20:36 + | +LL | assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err()); + | ^^^^^^^^^^^^^ attempt to divide with overflow + +error: this arithmetic operation will overflow + --> $DIR/issue-8460-const.rs:22:36 + | +LL | assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err()); + | ^^^^^^^^^^^^^ attempt to divide with overflow + +error: this arithmetic operation will overflow + --> $DIR/issue-8460-const.rs:24:36 + | +LL | assert!(thread::spawn(move|| { i128::MIN / -1; }).join().is_err()); + | ^^^^^^^^^^^^^^ attempt to divide with overflow + +error: this operation will panic at runtime + --> $DIR/issue-8460-const.rs:26:36 + | +LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); + | ^^^^^^^^^^ attempt to divide by zero + | + = note: `#[deny(panic)]` on by default + +error: this operation will panic at runtime + --> $DIR/issue-8460-const.rs:28:36 + | +LL | assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err()); + | ^^^^^^^ attempt to divide by zero + +error: this operation will panic at runtime + --> $DIR/issue-8460-const.rs:30:36 + | +LL | assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err()); + | ^^^^^^^^ attempt to divide by zero + +error: this operation will panic at runtime + --> $DIR/issue-8460-const.rs:32:36 + | +LL | assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err()); + | ^^^^^^^^ attempt to divide by zero + +error: this operation will panic at runtime + --> $DIR/issue-8460-const.rs:34:36 + | +LL | assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err()); + | ^^^^^^^^ attempt to divide by zero + +error: this operation will panic at runtime + --> $DIR/issue-8460-const.rs:36:36 + | +LL | assert!(thread::spawn(move|| { 1i128 / 0; }).join().is_err()); + | ^^^^^^^^^ attempt to divide by zero + +error: this arithmetic operation will overflow + --> $DIR/issue-8460-const.rs:38:36 + | +LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err()); + | ^^^^^^^^^^^^^^^ attempt to calculate the remainder with overflow + +error: this arithmetic operation will overflow + --> $DIR/issue-8460-const.rs:40:36 + | +LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err()); + | ^^^^^^^^^^^^ attempt to calculate the remainder with overflow + +error: this arithmetic operation will overflow + --> $DIR/issue-8460-const.rs:42:36 + | +LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err()); + | ^^^^^^^^^^^^^ attempt to calculate the remainder with overflow + +error: this arithmetic operation will overflow + --> $DIR/issue-8460-const.rs:44:36 + | +LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err()); + | ^^^^^^^^^^^^^ attempt to calculate the remainder with overflow + +error: this arithmetic operation will overflow + --> $DIR/issue-8460-const.rs:46:36 + | +LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err()); + | ^^^^^^^^^^^^^ attempt to calculate the remainder with overflow + +error: this arithmetic operation will overflow + --> $DIR/issue-8460-const.rs:48:36 + | +LL | assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err()); + | ^^^^^^^^^^^^^^ attempt to calculate the remainder with overflow + +error: this operation will panic at runtime + --> $DIR/issue-8460-const.rs:50:36 + | +LL | assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err()); + | ^^^^^^^^^^ attempt to calculate the remainder with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/issue-8460-const.rs:52:36 + | +LL | assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err()); + | ^^^^^^^ attempt to calculate the remainder with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/issue-8460-const.rs:54:36 + | +LL | assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err()); + | ^^^^^^^^ attempt to calculate the remainder with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/issue-8460-const.rs:56:36 + | +LL | assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err()); + | ^^^^^^^^ attempt to calculate the remainder with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/issue-8460-const.rs:58:36 + | +LL | assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err()); + | ^^^^^^^^ attempt to calculate the remainder with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/issue-8460-const.rs:60:36 + | +LL | assert!(thread::spawn(move|| { 1i128 % 0; }).join().is_err()); + | ^^^^^^^^^ attempt to calculate the remainder with a divisor of zero + +error: aborting due to 24 previous errors + diff --git a/src/test/ui/issues/issue-8460-const.rs b/src/test/ui/issues/issue-8460-const.rs index 5866cef2d2c7..3ab873952e25 100644 --- a/src/test/ui/issues/issue-8460-const.rs +++ b/src/test/ui/issues/issue-8460-const.rs @@ -1,5 +1,9 @@ +// revisions: debug opt opt_with_overflow_checks +//[debug]compile-flags: -C opt-level=0 +//[opt]compile-flags: -O +//[opt_with_overflow_checks]compile-flags: -C overflow-checks=on -O + // build-fail -// compile-flags: -O #![deny(const_err)] @@ -8,63 +12,51 @@ use std::thread; fn main() { assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err()); - //~^ ERROR attempt to divide with overflow - //~| ERROR this expression will panic at runtime + //~^ ERROR arithmetic operation will overflow assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err()); - //~^ ERROR attempt to divide with overflow - //~| ERROR this expression will panic at runtime + //~^ ERROR arithmetic operation will overflow assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err()); - //~^ ERROR attempt to divide with overflow - //~| ERROR this expression will panic at runtime + //~^ ERROR arithmetic operation will overflow assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err()); - //~^ ERROR attempt to divide with overflow - //~| ERROR this expression will panic at runtime + //~^ ERROR arithmetic operation will overflow assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err()); - //~^ ERROR attempt to divide with overflow - //~| ERROR this expression will panic at runtime + //~^ ERROR arithmetic operation will overflow assert!(thread::spawn(move|| { i128::MIN / -1; }).join().is_err()); - //~^ ERROR attempt to divide with overflow - //~| ERROR this expression will panic at runtime + //~^ ERROR arithmetic operation will overflow assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); - //~^ ERROR attempt to divide by zero + //~^ ERROR operation will panic assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err()); - //~^ ERROR attempt to divide by zero + //~^ ERROR operation will panic assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err()); - //~^ ERROR attempt to divide by zero + //~^ ERROR operation will panic assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err()); - //~^ ERROR attempt to divide by zero + //~^ ERROR operation will panic assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err()); - //~^ ERROR attempt to divide by zero + //~^ ERROR operation will panic assert!(thread::spawn(move|| { 1i128 / 0; }).join().is_err()); - //~^ ERROR attempt to divide by zero + //~^ ERROR operation will panic assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err()); - //~^ ERROR attempt to calculate the remainder with overflow - //~| ERROR this expression will panic at runtime + //~^ ERROR arithmetic operation will overflow assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err()); - //~^ ERROR attempt to calculate the remainder with overflow - //~| ERROR this expression will panic at runtime + //~^ ERROR arithmetic operation will overflow assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err()); - //~^ ERROR attempt to calculate the remainder with overflow - //~| ERROR this expression will panic at runtime + //~^ ERROR arithmetic operation will overflow assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err()); - //~^ ERROR attempt to calculate the remainder with overflow - //~| ERROR this expression will panic at runtime + //~^ ERROR arithmetic operation will overflow assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err()); - //~^ ERROR attempt to calculate the remainder with overflow - //~| ERROR this expression will panic at runtime + //~^ ERROR arithmetic operation will overflow assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err()); - //~^ ERROR attempt to calculate the remainder with overflow - //~| ERROR this expression will panic at runtime + //~^ ERROR arithmetic operation will overflow assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err()); - //~^ ERROR attempt to calculate the remainder with a divisor of zero + //~^ ERROR operation will panic assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err()); - //~^ ERROR attempt to calculate the remainder with a divisor of zero + //~^ ERROR operation will panic assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err()); - //~^ ERROR attempt to calculate the remainder with a divisor of zero + //~^ ERROR operation will panic assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err()); - //~^ ERROR attempt to calculate the remainder with a divisor of zero + //~^ ERROR operation will panic assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err()); - //~^ ERROR attempt to calculate the remainder with a divisor of zero + //~^ ERROR operation will panic assert!(thread::spawn(move|| { 1i128 % 0; }).join().is_err()); - //~^ ERROR attempt to calculate the remainder with a divisor of zero + //~^ ERROR operation will panic } diff --git a/src/test/ui/issues/issue-8460-const.stderr b/src/test/ui/issues/issue-8460-const.stderr deleted file mode 100644 index d7373948cb9e..000000000000 --- a/src/test/ui/issues/issue-8460-const.stderr +++ /dev/null @@ -1,224 +0,0 @@ -error: attempt to divide with overflow - --> $DIR/issue-8460-const.rs:10:36 - | -LL | assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^^^ - | -note: the lint level is defined here - --> $DIR/issue-8460-const.rs:4:9 - | -LL | #![deny(const_err)] - | ^^^^^^^^^ - -error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:10:36 - | -LL | assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^^^ attempt to divide with overflow - -error: attempt to divide with overflow - --> $DIR/issue-8460-const.rs:13:36 - | -LL | assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^ - -error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:13:36 - | -LL | assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^ attempt to divide with overflow - -error: attempt to divide with overflow - --> $DIR/issue-8460-const.rs:16:36 - | -LL | assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^ - -error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:16:36 - | -LL | assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to divide with overflow - -error: attempt to divide with overflow - --> $DIR/issue-8460-const.rs:19:36 - | -LL | assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^ - -error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:19:36 - | -LL | assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to divide with overflow - -error: attempt to divide with overflow - --> $DIR/issue-8460-const.rs:22:36 - | -LL | assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^ - -error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:22:36 - | -LL | assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to divide with overflow - -error: attempt to divide with overflow - --> $DIR/issue-8460-const.rs:25:36 - | -LL | assert!(thread::spawn(move|| { i128::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^^ - -error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:25:36 - | -LL | assert!(thread::spawn(move|| { i128::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^^ attempt to divide with overflow - -error: attempt to divide by zero - --> $DIR/issue-8460-const.rs:28:36 - | -LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); - | ^^^^^^^^^^ - -error: attempt to divide by zero - --> $DIR/issue-8460-const.rs:30:36 - | -LL | assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err()); - | ^^^^^^^ - -error: attempt to divide by zero - --> $DIR/issue-8460-const.rs:32:36 - | -LL | assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err()); - | ^^^^^^^^ - -error: attempt to divide by zero - --> $DIR/issue-8460-const.rs:34:36 - | -LL | assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err()); - | ^^^^^^^^ - -error: attempt to divide by zero - --> $DIR/issue-8460-const.rs:36:36 - | -LL | assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err()); - | ^^^^^^^^ - -error: attempt to divide by zero - --> $DIR/issue-8460-const.rs:38:36 - | -LL | assert!(thread::spawn(move|| { 1i128 / 0; }).join().is_err()); - | ^^^^^^^^^ - -error: attempt to calculate the remainder with overflow - --> $DIR/issue-8460-const.rs:40:36 - | -LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^^^ - -error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:40:36 - | -LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^^^ attempt to calculate the remainder with overflow - -error: attempt to calculate the remainder with overflow - --> $DIR/issue-8460-const.rs:43:36 - | -LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^ - -error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:43:36 - | -LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^ attempt to calculate the remainder with overflow - -error: attempt to calculate the remainder with overflow - --> $DIR/issue-8460-const.rs:46:36 - | -LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ - -error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:46:36 - | -LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to calculate the remainder with overflow - -error: attempt to calculate the remainder with overflow - --> $DIR/issue-8460-const.rs:49:36 - | -LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ - -error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:49:36 - | -LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to calculate the remainder with overflow - -error: attempt to calculate the remainder with overflow - --> $DIR/issue-8460-const.rs:52:36 - | -LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ - -error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:52:36 - | -LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to calculate the remainder with overflow - -error: attempt to calculate the remainder with overflow - --> $DIR/issue-8460-const.rs:55:36 - | -LL | assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^^ - -error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:55:36 - | -LL | assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^^ attempt to calculate the remainder with overflow - -error: attempt to calculate the remainder with a divisor of zero - --> $DIR/issue-8460-const.rs:58:36 - | -LL | assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err()); - | ^^^^^^^^^^ - -error: attempt to calculate the remainder with a divisor of zero - --> $DIR/issue-8460-const.rs:60:36 - | -LL | assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err()); - | ^^^^^^^ - -error: attempt to calculate the remainder with a divisor of zero - --> $DIR/issue-8460-const.rs:62:36 - | -LL | assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err()); - | ^^^^^^^^ - -error: attempt to calculate the remainder with a divisor of zero - --> $DIR/issue-8460-const.rs:64:36 - | -LL | assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err()); - | ^^^^^^^^ - -error: attempt to calculate the remainder with a divisor of zero - --> $DIR/issue-8460-const.rs:66:36 - | -LL | assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err()); - | ^^^^^^^^ - -error: attempt to calculate the remainder with a divisor of zero - --> $DIR/issue-8460-const.rs:68:36 - | -LL | assert!(thread::spawn(move|| { 1i128 % 0; }).join().is_err()); - | ^^^^^^^^^ - -error: aborting due to 36 previous errors - diff --git a/src/test/ui/issues/issue-8460-const2.rs b/src/test/ui/issues/issue-8460-const2.rs deleted file mode 100644 index afea859bb65a..000000000000 --- a/src/test/ui/issues/issue-8460-const2.rs +++ /dev/null @@ -1,58 +0,0 @@ -// build-fail -// compile-flags: -C overflow-checks=on -O - -#![deny(const_err)] - -use std::{isize, i8, i16, i32, i64, i128}; -use std::thread; - -fn main() { - assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err()); - //~^ ERROR attempt to divide with overflow - assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err()); - //~^ ERROR attempt to divide with overflow - assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err()); - //~^ ERROR attempt to divide with overflow - assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err()); - //~^ ERROR attempt to divide with overflow - assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err()); - //~^ ERROR attempt to divide with overflow - assert!(thread::spawn(move|| { i128::MIN / -1; }).join().is_err()); - //~^ ERROR attempt to divide with overflow - assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); - //~^ ERROR attempt to divide by zero - assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err()); - //~^ ERROR attempt to divide by zero - assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err()); - //~^ ERROR attempt to divide by zero - assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err()); - //~^ ERROR attempt to divide by zero - assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err()); - //~^ ERROR attempt to divide by zero - assert!(thread::spawn(move|| { 1i128 / 0; }).join().is_err()); - //~^ ERROR attempt to divide by zero - assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err()); - //~^ ERROR attempt to calculate the remainder with overflow - assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err()); - //~^ ERROR attempt to calculate the remainder with overflow - assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err()); - //~^ ERROR attempt to calculate the remainder with overflow - assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err()); - //~^ ERROR attempt to calculate the remainder with overflow - assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err()); - //~^ ERROR attempt to calculate the remainder with overflow - assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err()); - //~^ ERROR attempt to calculate the remainder with overflow - assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err()); - //~^ ERROR attempt to calculate the remainder with a divisor of zero - assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err()); - //~^ ERROR attempt to calculate the remainder with a divisor of zero - assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err()); - //~^ ERROR attempt to calculate the remainder with a divisor of zero - assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err()); - //~^ ERROR attempt to calculate the remainder with a divisor of zero - assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err()); - //~^ ERROR attempt to calculate the remainder with a divisor of zero - assert!(thread::spawn(move|| { 1i128 % 0; }).join().is_err()); - //~^ ERROR attempt to calculate the remainder with a divisor of zero -} diff --git a/src/test/ui/issues/issue-8460-const2.stderr b/src/test/ui/issues/issue-8460-const2.stderr deleted file mode 100644 index e25d560fe0ce..000000000000 --- a/src/test/ui/issues/issue-8460-const2.stderr +++ /dev/null @@ -1,152 +0,0 @@ -error: attempt to divide with overflow - --> $DIR/issue-8460-const2.rs:10:36 - | -LL | assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^^^ - | -note: the lint level is defined here - --> $DIR/issue-8460-const2.rs:4:9 - | -LL | #![deny(const_err)] - | ^^^^^^^^^ - -error: attempt to divide with overflow - --> $DIR/issue-8460-const2.rs:12:36 - | -LL | assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^ - -error: attempt to divide with overflow - --> $DIR/issue-8460-const2.rs:14:36 - | -LL | assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^ - -error: attempt to divide with overflow - --> $DIR/issue-8460-const2.rs:16:36 - | -LL | assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^ - -error: attempt to divide with overflow - --> $DIR/issue-8460-const2.rs:18:36 - | -LL | assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^ - -error: attempt to divide with overflow - --> $DIR/issue-8460-const2.rs:20:36 - | -LL | assert!(thread::spawn(move|| { i128::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^^ - -error: attempt to divide by zero - --> $DIR/issue-8460-const2.rs:22:36 - | -LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); - | ^^^^^^^^^^ - -error: attempt to divide by zero - --> $DIR/issue-8460-const2.rs:24:36 - | -LL | assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err()); - | ^^^^^^^ - -error: attempt to divide by zero - --> $DIR/issue-8460-const2.rs:26:36 - | -LL | assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err()); - | ^^^^^^^^ - -error: attempt to divide by zero - --> $DIR/issue-8460-const2.rs:28:36 - | -LL | assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err()); - | ^^^^^^^^ - -error: attempt to divide by zero - --> $DIR/issue-8460-const2.rs:30:36 - | -LL | assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err()); - | ^^^^^^^^ - -error: attempt to divide by zero - --> $DIR/issue-8460-const2.rs:32:36 - | -LL | assert!(thread::spawn(move|| { 1i128 / 0; }).join().is_err()); - | ^^^^^^^^^ - -error: attempt to calculate the remainder with overflow - --> $DIR/issue-8460-const2.rs:34:36 - | -LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^^^ - -error: attempt to calculate the remainder with overflow - --> $DIR/issue-8460-const2.rs:36:36 - | -LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^ - -error: attempt to calculate the remainder with overflow - --> $DIR/issue-8460-const2.rs:38:36 - | -LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ - -error: attempt to calculate the remainder with overflow - --> $DIR/issue-8460-const2.rs:40:36 - | -LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ - -error: attempt to calculate the remainder with overflow - --> $DIR/issue-8460-const2.rs:42:36 - | -LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ - -error: attempt to calculate the remainder with overflow - --> $DIR/issue-8460-const2.rs:44:36 - | -LL | assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^^ - -error: attempt to calculate the remainder with a divisor of zero - --> $DIR/issue-8460-const2.rs:46:36 - | -LL | assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err()); - | ^^^^^^^^^^ - -error: attempt to calculate the remainder with a divisor of zero - --> $DIR/issue-8460-const2.rs:48:36 - | -LL | assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err()); - | ^^^^^^^ - -error: attempt to calculate the remainder with a divisor of zero - --> $DIR/issue-8460-const2.rs:50:36 - | -LL | assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err()); - | ^^^^^^^^ - -error: attempt to calculate the remainder with a divisor of zero - --> $DIR/issue-8460-const2.rs:52:36 - | -LL | assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err()); - | ^^^^^^^^ - -error: attempt to calculate the remainder with a divisor of zero - --> $DIR/issue-8460-const2.rs:54:36 - | -LL | assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err()); - | ^^^^^^^^ - -error: attempt to calculate the remainder with a divisor of zero - --> $DIR/issue-8460-const2.rs:56:36 - | -LL | assert!(thread::spawn(move|| { 1i128 % 0; }).join().is_err()); - | ^^^^^^^^^ - -error: aborting due to 24 previous errors -