From 35c9e5f1229d8b634ebd98c49e35c74e237e17f7 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 1 Sep 2019 22:05:50 +0900 Subject: [PATCH 1/7] Fix const_err with `-(-0.0)` --- src/librustc_mir/transform/const_prop.rs | 14 +------------- src/test/ui/consts/const-err2.rs | 1 - src/test/ui/consts/const-err2.stderr | 20 +++++++------------- src/test/ui/consts/issue-64059.rs | 5 +++++ 4 files changed, 13 insertions(+), 27 deletions(-) create mode 100644 src/test/ui/consts/issue-64059.rs diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs index f261fdc268b5b..00118c05c9451 100644 --- a/src/librustc_mir/transform/const_prop.rs +++ b/src/librustc_mir/transform/const_prop.rs @@ -6,7 +6,7 @@ use std::cell::Cell; use rustc::hir::def::DefKind; use rustc::mir::{ AggregateKind, Constant, Location, Place, PlaceBase, Body, Operand, Rvalue, - Local, NullOp, UnOp, StatementKind, Statement, LocalKind, Static, StaticKind, + Local, NullOp, StatementKind, Statement, LocalKind, Static, StaticKind, TerminatorKind, Terminator, ClearCrossCrate, SourceInfo, BinOp, ProjectionElem, SourceScope, SourceScopeLocalData, LocalDecl, }; @@ -407,18 +407,6 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { let arg = self.eval_operand(arg, source_info)?; let val = self.use_ecx(source_info, |this| { let prim = this.ecx.read_immediate(arg)?; - match op { - UnOp::Neg => { - // Need to do overflow check here: For actual CTFE, MIR - // generation emits code that does this before calling the op. - if prim.to_bits()? == (1 << (prim.layout.size.bits() - 1)) { - throw_panic!(OverflowNeg) - } - } - UnOp::Not => { - // Cannot overflow - } - } // Now run the actual operation. this.ecx.unary_op(op, prim) })?; diff --git a/src/test/ui/consts/const-err2.rs b/src/test/ui/consts/const-err2.rs index a5f685a159b39..5aab1972a9bd5 100644 --- a/src/test/ui/consts/const-err2.rs +++ b/src/test/ui/consts/const-err2.rs @@ -13,7 +13,6 @@ fn black_box(_: T) { fn main() { let a = -std::i8::MIN; - //~^ ERROR const_err let b = 200u8 + 200u8 + 200u8; //~^ ERROR const_err let c = 200u8 * 4; diff --git a/src/test/ui/consts/const-err2.stderr b/src/test/ui/consts/const-err2.stderr index 659c3afc618a9..63d037764a13d 100644 --- a/src/test/ui/consts/const-err2.stderr +++ b/src/test/ui/consts/const-err2.stderr @@ -1,8 +1,8 @@ error: this expression will panic at runtime - --> $DIR/const-err2.rs:15:13 + --> $DIR/const-err2.rs:16:13 | -LL | let a = -std::i8::MIN; - | ^^^^^^^^^^^^^ attempt to negate with overflow +LL | let b = 200u8 + 200u8 + 200u8; + | ^^^^^^^^^^^^^ attempt to add with overflow | note: lint level defined here --> $DIR/const-err2.rs:8:9 @@ -11,28 +11,22 @@ LL | #![deny(const_err)] | ^^^^^^^^^ error: this expression will panic at runtime - --> $DIR/const-err2.rs:17:13 - | -LL | let b = 200u8 + 200u8 + 200u8; - | ^^^^^^^^^^^^^ attempt to add with overflow - -error: this expression will panic at runtime - --> $DIR/const-err2.rs:19:13 + --> $DIR/const-err2.rs:18:13 | LL | let c = 200u8 * 4; | ^^^^^^^^^ attempt to multiply with overflow error: this expression will panic at runtime - --> $DIR/const-err2.rs:21:13 + --> $DIR/const-err2.rs:20: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:23:14 + --> $DIR/const-err2.rs:22:14 | LL | let _e = [5u8][1]; | ^^^^^^^^ -error: aborting due to 5 previous errors +error: aborting due to 4 previous errors diff --git a/src/test/ui/consts/issue-64059.rs b/src/test/ui/consts/issue-64059.rs new file mode 100644 index 0000000000000..c4c895fef66cf --- /dev/null +++ b/src/test/ui/consts/issue-64059.rs @@ -0,0 +1,5 @@ +// run-pass + +fn main() { + let _ = -(-0.0); +} From 3a6aadaa8c915c3dea42c0b1fb6d96f227166148 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Mon, 2 Sep 2019 01:05:38 +0900 Subject: [PATCH 2/7] Add `opt-level` check --- src/librustc_mir/transform/const_prop.rs | 16 ++- src/test/ui/consts/const-err2.rs | 3 - src/test/ui/consts/const-err2.stderr | 28 +--- .../ui/consts/const-eval/promoted_errors.rs | 1 - .../consts/const-eval/promoted_errors.stderr | 30 ++--- ...t-method-self-inherit-builtin-trait.stderr | 6 + src/test/ui/issues/issue-8460-const.rs | 10 -- src/test/ui/issues/issue-8460-const.stderr | 120 +++++------------- 8 files changed, 67 insertions(+), 147 deletions(-) create mode 100644 src/test/ui/issues/issue-8171-default-method-self-inherit-builtin-trait.stderr diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs index 00118c05c9451..37e14004ce841 100644 --- a/src/librustc_mir/transform/const_prop.rs +++ b/src/librustc_mir/transform/const_prop.rs @@ -6,7 +6,7 @@ use std::cell::Cell; use rustc::hir::def::DefKind; use rustc::mir::{ AggregateKind, Constant, Location, Place, PlaceBase, Body, Operand, Rvalue, - Local, NullOp, StatementKind, Statement, LocalKind, Static, StaticKind, + Local, NullOp, UnOp, StatementKind, Statement, LocalKind, Static, StaticKind, TerminatorKind, Terminator, ClearCrossCrate, SourceInfo, BinOp, ProjectionElem, SourceScope, SourceScopeLocalData, LocalDecl, }; @@ -405,8 +405,20 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { } let arg = self.eval_operand(arg, source_info)?; + let is_release_mode = self.tcx.sess.opts.debugging_opts.mir_opt_level >= 2; let val = self.use_ecx(source_info, |this| { let prim = this.ecx.read_immediate(arg)?; + match op { + UnOp::Neg => { + if is_release_mode + && prim.to_bits()? == (1 << (prim.layout.size.bits() - 1)) { + throw_panic!(OverflowNeg) + } + } + UnOp::Not => { + // Cannot overflow + } + } // Now run the actual operation. this.ecx.unary_op(op, prim) })?; @@ -473,7 +485,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { Scalar::from_bool(overflow).into(), ) } else { - if overflow { + if self.tcx.sess.opts.debugging_opts.mir_opt_level >= 2 && overflow { let err = err_panic!(Overflow(op)).into(); let _: Option<()> = self.use_ecx(source_info, |_| Err(err)); return None; diff --git a/src/test/ui/consts/const-err2.rs b/src/test/ui/consts/const-err2.rs index 5aab1972a9bd5..6da6addf60a1c 100644 --- a/src/test/ui/consts/const-err2.rs +++ b/src/test/ui/consts/const-err2.rs @@ -14,11 +14,8 @@ fn black_box(_: T) { fn main() { let a = -std::i8::MIN; let b = 200u8 + 200u8 + 200u8; - //~^ 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); diff --git a/src/test/ui/consts/const-err2.stderr b/src/test/ui/consts/const-err2.stderr index 63d037764a13d..30855fd215ff3 100644 --- a/src/test/ui/consts/const-err2.stderr +++ b/src/test/ui/consts/const-err2.stderr @@ -1,8 +1,8 @@ -error: this expression will panic at runtime - --> $DIR/const-err2.rs:16:13 +error: index out of bounds: the len is 1 but the index is 1 + --> $DIR/const-err2.rs:19:14 | -LL | let b = 200u8 + 200u8 + 200u8; - | ^^^^^^^^^^^^^ attempt to add with overflow +LL | let _e = [5u8][1]; + | ^^^^^^^^ | note: lint level defined here --> $DIR/const-err2.rs:8:9 @@ -10,23 +10,5 @@ note: lint level defined here LL | #![deny(const_err)] | ^^^^^^^^^ -error: this expression will panic at runtime - --> $DIR/const-err2.rs:18:13 - | -LL | let c = 200u8 * 4; - | ^^^^^^^^^ attempt to multiply with overflow - -error: this expression will panic at runtime - --> $DIR/const-err2.rs:20: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:22:14 - | -LL | let _e = [5u8][1]; - | ^^^^^^^^ - -error: aborting due to 4 previous errors +error: aborting due to previous error diff --git a/src/test/ui/consts/const-eval/promoted_errors.rs b/src/test/ui/consts/const-eval/promoted_errors.rs index cd989731452b3..a9a7a66fe614f 100644 --- a/src/test/ui/consts/const-eval/promoted_errors.rs +++ b/src/test/ui/consts/const-eval/promoted_errors.rs @@ -5,7 +5,6 @@ fn main() { println!("{}", 0u32 - 1); let _x = 0u32 - 1; - //~^ ERROR this expression will panic at runtime [const_err] println!("{}", 1/(1-1)); //~^ ERROR attempt to divide by zero [const_err] //~| ERROR reaching this expression at runtime will panic or abort [const_err] diff --git a/src/test/ui/consts/const-eval/promoted_errors.stderr b/src/test/ui/consts/const-eval/promoted_errors.stderr index 40d5c73e86679..3940fa13d7892 100644 --- a/src/test/ui/consts/const-eval/promoted_errors.stderr +++ b/src/test/ui/consts/const-eval/promoted_errors.stderr @@ -1,8 +1,8 @@ -error: this expression will panic at runtime - --> $DIR/promoted_errors.rs:7:14 +error: attempt to divide by zero + --> $DIR/promoted_errors.rs:8:20 | -LL | let _x = 0u32 - 1; - | ^^^^^^^^ attempt to subtract with overflow +LL | println!("{}", 1/(1-1)); + | ^^^^^^^ | note: lint level defined here --> $DIR/promoted_errors.rs:3:9 @@ -10,53 +10,47 @@ note: lint level defined here LL | #![deny(const_err)] | ^^^^^^^^^ -error: attempt to divide by zero - --> $DIR/promoted_errors.rs:9:20 - | -LL | println!("{}", 1/(1-1)); - | ^^^^^^^ - error: reaching this expression at runtime will panic or abort - --> $DIR/promoted_errors.rs:9:20 + --> $DIR/promoted_errors.rs:8:20 | LL | println!("{}", 1/(1-1)); | ^^^^^^^ attempt to divide by zero error: attempt to divide by zero - --> $DIR/promoted_errors.rs:12:14 + --> $DIR/promoted_errors.rs:11:14 | LL | let _x = 1/(1-1); | ^^^^^^^ error: this expression will panic at runtime - --> $DIR/promoted_errors.rs:12:14 + --> $DIR/promoted_errors.rs:11:14 | LL | let _x = 1/(1-1); | ^^^^^^^ attempt to divide by zero error: attempt to divide by zero - --> $DIR/promoted_errors.rs:15:20 + --> $DIR/promoted_errors.rs:14:20 | LL | println!("{}", 1/(false as u32)); | ^^^^^^^^^^^^^^^^ error: reaching this expression at runtime will panic or abort - --> $DIR/promoted_errors.rs:15:20 + --> $DIR/promoted_errors.rs:14:20 | LL | println!("{}", 1/(false as u32)); | ^^^^^^^^^^^^^^^^ attempt to divide by zero error: attempt to divide by zero - --> $DIR/promoted_errors.rs:18:14 + --> $DIR/promoted_errors.rs:17:14 | LL | let _x = 1/(false as u32); | ^^^^^^^^^^^^^^^^ error: this expression will panic at runtime - --> $DIR/promoted_errors.rs:18:14 + --> $DIR/promoted_errors.rs:17:14 | LL | let _x = 1/(false as u32); | ^^^^^^^^^^^^^^^^ attempt to divide by zero -error: aborting due to 9 previous errors +error: aborting due to 8 previous errors diff --git a/src/test/ui/issues/issue-8171-default-method-self-inherit-builtin-trait.stderr b/src/test/ui/issues/issue-8171-default-method-self-inherit-builtin-trait.stderr new file mode 100644 index 0000000000000..5160c9e72a9c4 --- /dev/null +++ b/src/test/ui/issues/issue-8171-default-method-self-inherit-builtin-trait.stderr @@ -0,0 +1,6 @@ +error: failed to remove $TEST_BUILD_DIR/issues/issue-8171-default-method-self-inherit-builtin-trait/issue-8171-default-method-self-inherit-builtin-trait.issue_8171_default_method_self_inherit_builtin_trait.7rcbfp3g-cgu.0.rcgu.o: 指定されたパスが見つかりません。 (os error 3) + +error: failed to remove $TEST_BUILD_DIR/issues/issue-8171-default-method-self-inherit-builtin-trait/issue-8171-default-method-self-inherit-builtin-trait.issue_8171_default_method_self_inherit_builtin_trait.7rcbfp3g-cgu.1.rcgu.o: 指定されたパスが見つかりません。 (os error 3) + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/issues/issue-8460-const.rs b/src/test/ui/issues/issue-8460-const.rs index 611d280f774c0..6a5b98fa9b190 100644 --- a/src/test/ui/issues/issue-8460-const.rs +++ b/src/test/ui/issues/issue-8460-const.rs @@ -6,19 +6,14 @@ 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 assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err()); //~^ ERROR attempt to divide with overflow - //~| ERROR this expression will panic at runtime assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err()); //~^ ERROR attempt to divide with overflow - //~| ERROR this expression will panic at runtime assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err()); //~^ ERROR attempt to divide with overflow - //~| ERROR this expression will panic at runtime assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err()); //~^ ERROR attempt to divide with overflow - //~| ERROR this expression will panic at runtime assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); //~^ ERROR attempt to divide by zero //~| ERROR this expression will panic at runtime @@ -36,19 +31,14 @@ fn main() { //~| ERROR this expression will panic at runtime 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 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 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 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 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 assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err()); //~^ ERROR attempt to calculate the remainder with a divisor of zero //~| ERROR this expression will panic at runtime diff --git a/src/test/ui/issues/issue-8460-const.stderr b/src/test/ui/issues/issue-8460-const.stderr index 31b1da4f804ab..b9fbf0bdaa609 100644 --- a/src/test/ui/issues/issue-8460-const.stderr +++ b/src/test/ui/issues/issue-8460-const.stderr @@ -10,239 +10,179 @@ note: lint level defined here LL | #![deny(const_err)] | ^^^^^^^^^ -error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:7: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:10:36 + --> $DIR/issue-8460-const.rs:9:36 | LL | assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^ -error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:10: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:13:36 + --> $DIR/issue-8460-const.rs:11:36 | LL | assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^ -error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:13: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:16:36 + --> $DIR/issue-8460-const.rs:13:36 | LL | assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^ -error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:16: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:19:36 + --> $DIR/issue-8460-const.rs:15:36 | LL | assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^ -error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:19:36 - | -LL | assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to divide with overflow - error: attempt to divide by zero - --> $DIR/issue-8460-const.rs:22:36 + --> $DIR/issue-8460-const.rs:17:36 | LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); | ^^^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:22:36 + --> $DIR/issue-8460-const.rs:17:36 | LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); | ^^^^^^^^^^ attempt to divide by zero error: attempt to divide by zero - --> $DIR/issue-8460-const.rs:25:36 + --> $DIR/issue-8460-const.rs:20:36 | LL | assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err()); | ^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:25:36 + --> $DIR/issue-8460-const.rs:20:36 | LL | assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err()); | ^^^^^^^ attempt to divide by zero error: attempt to divide by zero - --> $DIR/issue-8460-const.rs:28:36 + --> $DIR/issue-8460-const.rs:23:36 | LL | assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err()); | ^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:28:36 + --> $DIR/issue-8460-const.rs:23:36 | LL | assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err()); | ^^^^^^^^ attempt to divide by zero error: attempt to divide by zero - --> $DIR/issue-8460-const.rs:31:36 + --> $DIR/issue-8460-const.rs:26:36 | LL | assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err()); | ^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:31:36 + --> $DIR/issue-8460-const.rs:26:36 | LL | assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err()); | ^^^^^^^^ attempt to divide by zero error: attempt to divide by zero - --> $DIR/issue-8460-const.rs:34:36 + --> $DIR/issue-8460-const.rs:29:36 | LL | assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err()); | ^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:34:36 + --> $DIR/issue-8460-const.rs:29:36 | LL | assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err()); | ^^^^^^^^ attempt to divide by zero error: attempt to calculate the remainder with overflow - --> $DIR/issue-8460-const.rs:37:36 + --> $DIR/issue-8460-const.rs:32:36 | LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^^^ -error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:37: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:40:36 + --> $DIR/issue-8460-const.rs:34:36 | LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^ -error: this expression will panic at runtime - --> $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: attempt to calculate the remainder with overflow - --> $DIR/issue-8460-const.rs:43:36 + --> $DIR/issue-8460-const.rs:36:36 | LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^ -error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:43: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:46:36 + --> $DIR/issue-8460-const.rs:38:36 | LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^ -error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:46: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:49:36 + --> $DIR/issue-8460-const.rs:40:36 | LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^ -error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:49: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 a divisor of zero - --> $DIR/issue-8460-const.rs:52:36 + --> $DIR/issue-8460-const.rs:42:36 | LL | assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err()); | ^^^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:52:36 + --> $DIR/issue-8460-const.rs:42:36 | LL | assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err()); | ^^^^^^^^^^ attempt to calculate the remainder with a divisor of zero error: attempt to calculate the remainder with a divisor of zero - --> $DIR/issue-8460-const.rs:55:36 + --> $DIR/issue-8460-const.rs:45:36 | LL | assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err()); | ^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:55:36 + --> $DIR/issue-8460-const.rs:45:36 | LL | assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err()); | ^^^^^^^ attempt to calculate the remainder with a divisor of zero error: attempt to calculate the remainder with a divisor of zero - --> $DIR/issue-8460-const.rs:58:36 + --> $DIR/issue-8460-const.rs:48:36 | LL | assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err()); | ^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:58:36 + --> $DIR/issue-8460-const.rs:48:36 | LL | assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err()); | ^^^^^^^^ attempt to calculate the remainder with a divisor of zero error: attempt to calculate the remainder with a divisor of zero - --> $DIR/issue-8460-const.rs:61:36 + --> $DIR/issue-8460-const.rs:51:36 | LL | assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err()); | ^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:61:36 + --> $DIR/issue-8460-const.rs:51:36 | LL | assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err()); | ^^^^^^^^ attempt to calculate the remainder with a divisor of zero error: attempt to calculate the remainder with a divisor of zero - --> $DIR/issue-8460-const.rs:64:36 + --> $DIR/issue-8460-const.rs:54:36 | LL | assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err()); | ^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:64:36 + --> $DIR/issue-8460-const.rs:54:36 | LL | assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err()); | ^^^^^^^^ attempt to calculate the remainder with a divisor of zero -error: aborting due to 40 previous errors +error: aborting due to 30 previous errors From 4a0872b37efbd982aed7e29f166e4ccb095f5779 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Mon, 2 Sep 2019 02:18:16 +0900 Subject: [PATCH 3/7] Add `overflow_check` check --- src/librustc_mir/transform/const_prop.rs | 8 ++++++-- ...-8171-default-method-self-inherit-builtin-trait.stderr | 6 ------ 2 files changed, 6 insertions(+), 8 deletions(-) delete mode 100644 src/test/ui/issues/issue-8171-default-method-self-inherit-builtin-trait.stderr diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs index 37e14004ce841..b43323687cda3 100644 --- a/src/librustc_mir/transform/const_prop.rs +++ b/src/librustc_mir/transform/const_prop.rs @@ -405,11 +405,13 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { } let arg = self.eval_operand(arg, source_info)?; - let is_release_mode = self.tcx.sess.opts.debugging_opts.mir_opt_level >= 2; + let is_release_mode = self.tcx.sess.overflow_checks(); let val = self.use_ecx(source_info, |this| { let prim = this.ecx.read_immediate(arg)?; match op { UnOp::Neg => { + // We don't have to check overflow here when we already + // check it in release mode. if is_release_mode && prim.to_bits()? == (1 << (prim.layout.size.bits() - 1)) { throw_panic!(OverflowNeg) @@ -485,7 +487,9 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { Scalar::from_bool(overflow).into(), ) } else { - if self.tcx.sess.opts.debugging_opts.mir_opt_level >= 2 && overflow { + // We don't have to check overflow here when we already + // check it in release mode. + if self.tcx.sess.overflow_checks() && overflow { let err = err_panic!(Overflow(op)).into(); let _: Option<()> = self.use_ecx(source_info, |_| Err(err)); return None; diff --git a/src/test/ui/issues/issue-8171-default-method-self-inherit-builtin-trait.stderr b/src/test/ui/issues/issue-8171-default-method-self-inherit-builtin-trait.stderr deleted file mode 100644 index 5160c9e72a9c4..0000000000000 --- a/src/test/ui/issues/issue-8171-default-method-self-inherit-builtin-trait.stderr +++ /dev/null @@ -1,6 +0,0 @@ -error: failed to remove $TEST_BUILD_DIR/issues/issue-8171-default-method-self-inherit-builtin-trait/issue-8171-default-method-self-inherit-builtin-trait.issue_8171_default_method_self_inherit_builtin_trait.7rcbfp3g-cgu.0.rcgu.o: 指定されたパスが見つかりません。 (os error 3) - -error: failed to remove $TEST_BUILD_DIR/issues/issue-8171-default-method-self-inherit-builtin-trait/issue-8171-default-method-self-inherit-builtin-trait.issue_8171_default_method_self_inherit_builtin_trait.7rcbfp3g-cgu.1.rcgu.o: 指定されたパスが見つかりません。 (os error 3) - -error: aborting due to 2 previous errors - From 8e9825aeb9bce905ed230733bf2a5b4b07f25eb9 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Mon, 2 Sep 2019 03:06:11 +0900 Subject: [PATCH 4/7] Fix overflow_check --- src/librustc_mir/transform/const_prop.rs | 14 +- src/test/ui/consts/const-err2.rs | 4 + src/test/ui/consts/const-err2.stderr | 34 ++++- .../ui/consts/const-eval/promoted_errors.rs | 1 + .../consts/const-eval/promoted_errors.stderr | 30 +++-- src/test/ui/consts/issue-64059.rs | 3 +- src/test/ui/consts/issue-64059.stderr | 10 ++ src/test/ui/issues/issue-8460-const.rs | 10 ++ src/test/ui/issues/issue-8460-const.stderr | 120 +++++++++++++----- 9 files changed, 170 insertions(+), 56 deletions(-) create mode 100644 src/test/ui/consts/issue-64059.stderr diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs index b43323687cda3..091e68cd0669c 100644 --- a/src/librustc_mir/transform/const_prop.rs +++ b/src/librustc_mir/transform/const_prop.rs @@ -405,14 +405,14 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { } let arg = self.eval_operand(arg, source_info)?; - let is_release_mode = self.tcx.sess.overflow_checks(); + let oflo_check = self.tcx.sess.overflow_checks(); let val = self.use_ecx(source_info, |this| { let prim = this.ecx.read_immediate(arg)?; match op { UnOp::Neg => { - // We don't have to check overflow here when we already - // check it in release mode. - if is_release_mode + // We check overflow in debug mode already + // so should only check in release mode. + if !oflo_check && prim.to_bits()? == (1 << (prim.layout.size.bits() - 1)) { throw_panic!(OverflowNeg) } @@ -487,9 +487,9 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { Scalar::from_bool(overflow).into(), ) } else { - // We don't have to check overflow here when we already - // check it in release mode. - if self.tcx.sess.overflow_checks() && overflow { + // We check overflow in debug mode already + // so should only check in release mode. + if !self.tcx.sess.overflow_checks() && overflow { let err = err_panic!(Overflow(op)).into(); let _: Option<()> = self.use_ecx(source_info, |_| Err(err)); return None; diff --git a/src/test/ui/consts/const-err2.rs b/src/test/ui/consts/const-err2.rs index 6da6addf60a1c..a5f685a159b39 100644 --- a/src/test/ui/consts/const-err2.rs +++ b/src/test/ui/consts/const-err2.rs @@ -13,9 +13,13 @@ fn black_box(_: T) { fn main() { let a = -std::i8::MIN; + //~^ ERROR const_err let b = 200u8 + 200u8 + 200u8; + //~^ 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); diff --git a/src/test/ui/consts/const-err2.stderr b/src/test/ui/consts/const-err2.stderr index 30855fd215ff3..659c3afc618a9 100644 --- a/src/test/ui/consts/const-err2.stderr +++ b/src/test/ui/consts/const-err2.stderr @@ -1,8 +1,8 @@ -error: index out of bounds: the len is 1 but the index is 1 - --> $DIR/const-err2.rs:19:14 +error: this expression will panic at runtime + --> $DIR/const-err2.rs:15:13 | -LL | let _e = [5u8][1]; - | ^^^^^^^^ +LL | let a = -std::i8::MIN; + | ^^^^^^^^^^^^^ attempt to negate with overflow | note: lint level defined here --> $DIR/const-err2.rs:8:9 @@ -10,5 +10,29 @@ note: lint level defined here LL | #![deny(const_err)] | ^^^^^^^^^ -error: aborting due to previous error +error: this expression will panic at runtime + --> $DIR/const-err2.rs:17:13 + | +LL | let b = 200u8 + 200u8 + 200u8; + | ^^^^^^^^^^^^^ attempt to add with overflow + +error: this expression will panic at runtime + --> $DIR/const-err2.rs:19:13 + | +LL | let c = 200u8 * 4; + | ^^^^^^^^^ attempt to multiply with overflow + +error: this expression will panic at runtime + --> $DIR/const-err2.rs:21: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:23:14 + | +LL | let _e = [5u8][1]; + | ^^^^^^^^ + +error: aborting due to 5 previous errors diff --git a/src/test/ui/consts/const-eval/promoted_errors.rs b/src/test/ui/consts/const-eval/promoted_errors.rs index a9a7a66fe614f..cd989731452b3 100644 --- a/src/test/ui/consts/const-eval/promoted_errors.rs +++ b/src/test/ui/consts/const-eval/promoted_errors.rs @@ -5,6 +5,7 @@ fn main() { println!("{}", 0u32 - 1); let _x = 0u32 - 1; + //~^ ERROR this expression will panic at runtime [const_err] println!("{}", 1/(1-1)); //~^ ERROR attempt to divide by zero [const_err] //~| ERROR reaching this expression at runtime will panic or abort [const_err] diff --git a/src/test/ui/consts/const-eval/promoted_errors.stderr b/src/test/ui/consts/const-eval/promoted_errors.stderr index 3940fa13d7892..40d5c73e86679 100644 --- a/src/test/ui/consts/const-eval/promoted_errors.stderr +++ b/src/test/ui/consts/const-eval/promoted_errors.stderr @@ -1,8 +1,8 @@ -error: attempt to divide by zero - --> $DIR/promoted_errors.rs:8:20 +error: this expression will panic at runtime + --> $DIR/promoted_errors.rs:7:14 | -LL | println!("{}", 1/(1-1)); - | ^^^^^^^ +LL | let _x = 0u32 - 1; + | ^^^^^^^^ attempt to subtract with overflow | note: lint level defined here --> $DIR/promoted_errors.rs:3:9 @@ -10,47 +10,53 @@ note: lint level defined here LL | #![deny(const_err)] | ^^^^^^^^^ +error: attempt to divide by zero + --> $DIR/promoted_errors.rs:9:20 + | +LL | println!("{}", 1/(1-1)); + | ^^^^^^^ + error: reaching this expression at runtime will panic or abort - --> $DIR/promoted_errors.rs:8:20 + --> $DIR/promoted_errors.rs:9:20 | LL | println!("{}", 1/(1-1)); | ^^^^^^^ attempt to divide by zero error: attempt to divide by zero - --> $DIR/promoted_errors.rs:11:14 + --> $DIR/promoted_errors.rs:12:14 | LL | let _x = 1/(1-1); | ^^^^^^^ error: this expression will panic at runtime - --> $DIR/promoted_errors.rs:11:14 + --> $DIR/promoted_errors.rs:12:14 | LL | let _x = 1/(1-1); | ^^^^^^^ attempt to divide by zero error: attempt to divide by zero - --> $DIR/promoted_errors.rs:14:20 + --> $DIR/promoted_errors.rs:15:20 | LL | println!("{}", 1/(false as u32)); | ^^^^^^^^^^^^^^^^ error: reaching this expression at runtime will panic or abort - --> $DIR/promoted_errors.rs:14:20 + --> $DIR/promoted_errors.rs:15:20 | LL | println!("{}", 1/(false as u32)); | ^^^^^^^^^^^^^^^^ attempt to divide by zero error: attempt to divide by zero - --> $DIR/promoted_errors.rs:17:14 + --> $DIR/promoted_errors.rs:18:14 | LL | let _x = 1/(false as u32); | ^^^^^^^^^^^^^^^^ error: this expression will panic at runtime - --> $DIR/promoted_errors.rs:17:14 + --> $DIR/promoted_errors.rs:18:14 | LL | let _x = 1/(false as u32); | ^^^^^^^^^^^^^^^^ attempt to divide by zero -error: aborting due to 8 previous errors +error: aborting due to 9 previous errors diff --git a/src/test/ui/consts/issue-64059.rs b/src/test/ui/consts/issue-64059.rs index c4c895fef66cf..30b8744cb7fa7 100644 --- a/src/test/ui/consts/issue-64059.rs +++ b/src/test/ui/consts/issue-64059.rs @@ -1,5 +1,4 @@ -// run-pass - fn main() { let _ = -(-0.0); + //~^ ERROR: this expression will panic at runtime } diff --git a/src/test/ui/consts/issue-64059.stderr b/src/test/ui/consts/issue-64059.stderr new file mode 100644 index 0000000000000..6f27653421bd6 --- /dev/null +++ b/src/test/ui/consts/issue-64059.stderr @@ -0,0 +1,10 @@ +error: this expression will panic at runtime + --> $DIR/issue-64059.rs:2:13 + | +LL | let _ = -(-0.0); + | ^^^^^^^ attempt to negate with overflow + | + = note: `#[deny(const_err)]` on by default + +error: aborting due to previous error + diff --git a/src/test/ui/issues/issue-8460-const.rs b/src/test/ui/issues/issue-8460-const.rs index 6a5b98fa9b190..611d280f774c0 100644 --- a/src/test/ui/issues/issue-8460-const.rs +++ b/src/test/ui/issues/issue-8460-const.rs @@ -6,14 +6,19 @@ 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 assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err()); //~^ ERROR attempt to divide with overflow + //~| ERROR this expression will panic at runtime assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err()); //~^ ERROR attempt to divide with overflow + //~| ERROR this expression will panic at runtime assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err()); //~^ ERROR attempt to divide with overflow + //~| ERROR this expression will panic at runtime assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err()); //~^ ERROR attempt to divide with overflow + //~| ERROR this expression will panic at runtime assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); //~^ ERROR attempt to divide by zero //~| ERROR this expression will panic at runtime @@ -31,14 +36,19 @@ fn main() { //~| ERROR this expression will panic at runtime 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 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 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 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 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 assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err()); //~^ ERROR attempt to calculate the remainder with a divisor of zero //~| ERROR this expression will panic at runtime diff --git a/src/test/ui/issues/issue-8460-const.stderr b/src/test/ui/issues/issue-8460-const.stderr index b9fbf0bdaa609..31b1da4f804ab 100644 --- a/src/test/ui/issues/issue-8460-const.stderr +++ b/src/test/ui/issues/issue-8460-const.stderr @@ -10,179 +10,239 @@ note: lint level defined here LL | #![deny(const_err)] | ^^^^^^^^^ +error: this expression will panic at runtime + --> $DIR/issue-8460-const.rs:7: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:9:36 + --> $DIR/issue-8460-const.rs:10:36 | LL | assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^ +error: this expression will panic at runtime + --> $DIR/issue-8460-const.rs:10: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:11:36 + --> $DIR/issue-8460-const.rs:13:36 | LL | assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^ -error: attempt to divide with overflow +error: this expression will panic at runtime --> $DIR/issue-8460-const.rs:13: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:16:36 + | LL | assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^ +error: this expression will panic at runtime + --> $DIR/issue-8460-const.rs:16: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:15:36 + --> $DIR/issue-8460-const.rs:19:36 | LL | assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^ +error: this expression will panic at runtime + --> $DIR/issue-8460-const.rs:19:36 + | +LL | assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err()); + | ^^^^^^^^^^^^^ attempt to divide with overflow + error: attempt to divide by zero - --> $DIR/issue-8460-const.rs:17:36 + --> $DIR/issue-8460-const.rs:22:36 | LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); | ^^^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:17:36 + --> $DIR/issue-8460-const.rs:22:36 | LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); | ^^^^^^^^^^ attempt to divide by zero error: attempt to divide by zero - --> $DIR/issue-8460-const.rs:20:36 + --> $DIR/issue-8460-const.rs:25:36 | LL | assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err()); | ^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:20:36 + --> $DIR/issue-8460-const.rs:25:36 | LL | assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err()); | ^^^^^^^ attempt to divide by zero error: attempt to divide by zero - --> $DIR/issue-8460-const.rs:23:36 + --> $DIR/issue-8460-const.rs:28:36 | LL | assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err()); | ^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:23:36 + --> $DIR/issue-8460-const.rs:28:36 | LL | assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err()); | ^^^^^^^^ attempt to divide by zero error: attempt to divide by zero - --> $DIR/issue-8460-const.rs:26:36 + --> $DIR/issue-8460-const.rs:31:36 | LL | assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err()); | ^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:26:36 + --> $DIR/issue-8460-const.rs:31:36 | LL | assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err()); | ^^^^^^^^ attempt to divide by zero error: attempt to divide by zero - --> $DIR/issue-8460-const.rs:29:36 + --> $DIR/issue-8460-const.rs:34:36 | LL | assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err()); | ^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:29:36 + --> $DIR/issue-8460-const.rs:34:36 | LL | assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err()); | ^^^^^^^^ attempt to divide by zero error: attempt to calculate the remainder with overflow - --> $DIR/issue-8460-const.rs:32:36 + --> $DIR/issue-8460-const.rs:37:36 | LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^^^ +error: this expression will panic at runtime + --> $DIR/issue-8460-const.rs:37: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:34:36 + --> $DIR/issue-8460-const.rs:40:36 | LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^ +error: this expression will panic at runtime + --> $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: attempt to calculate the remainder with overflow - --> $DIR/issue-8460-const.rs:36:36 + --> $DIR/issue-8460-const.rs:43:36 | LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^ +error: this expression will panic at runtime + --> $DIR/issue-8460-const.rs:43: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:38:36 + --> $DIR/issue-8460-const.rs:46:36 | LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^ +error: this expression will panic at runtime + --> $DIR/issue-8460-const.rs:46: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:40:36 + --> $DIR/issue-8460-const.rs:49:36 | LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^ +error: this expression will panic at runtime + --> $DIR/issue-8460-const.rs:49: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 a divisor of zero - --> $DIR/issue-8460-const.rs:42:36 + --> $DIR/issue-8460-const.rs:52:36 | LL | assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err()); | ^^^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:42:36 + --> $DIR/issue-8460-const.rs:52:36 | LL | assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err()); | ^^^^^^^^^^ attempt to calculate the remainder with a divisor of zero error: attempt to calculate the remainder with a divisor of zero - --> $DIR/issue-8460-const.rs:45:36 + --> $DIR/issue-8460-const.rs:55:36 | LL | assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err()); | ^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:45:36 + --> $DIR/issue-8460-const.rs:55:36 | LL | assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err()); | ^^^^^^^ attempt to calculate the remainder with a divisor of zero error: attempt to calculate the remainder with a divisor of zero - --> $DIR/issue-8460-const.rs:48:36 + --> $DIR/issue-8460-const.rs:58:36 | LL | assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err()); | ^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:48:36 + --> $DIR/issue-8460-const.rs:58:36 | LL | assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err()); | ^^^^^^^^ attempt to calculate the remainder with a divisor of zero error: attempt to calculate the remainder with a divisor of zero - --> $DIR/issue-8460-const.rs:51:36 + --> $DIR/issue-8460-const.rs:61:36 | LL | assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err()); | ^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:51:36 + --> $DIR/issue-8460-const.rs:61:36 | LL | assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err()); | ^^^^^^^^ attempt to calculate the remainder with a divisor of zero error: attempt to calculate the remainder with a divisor of zero - --> $DIR/issue-8460-const.rs:54:36 + --> $DIR/issue-8460-const.rs:64:36 | LL | assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err()); | ^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:54:36 + --> $DIR/issue-8460-const.rs:64:36 | LL | assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err()); | ^^^^^^^^ attempt to calculate the remainder with a divisor of zero -error: aborting due to 30 previous errors +error: aborting due to 40 previous errors From 0cd9c1623fb5858990892fed2fbf7c06e7b25f22 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Mon, 2 Sep 2019 03:40:35 +0900 Subject: [PATCH 5/7] Fix condition and tests' flags --- src/librustc_mir/transform/const_prop.rs | 1 + src/test/ui/consts/const-err2.rs | 2 + src/test/ui/consts/const-err2.stderr | 28 ++-- .../ui/consts/const-eval/promoted_errors.rs | 5 +- .../consts/const-eval/promoted_errors.stderr | 32 +++-- src/test/ui/consts/issue-64059.rs | 4 +- src/test/ui/consts/issue-64059.stderr | 10 -- src/test/ui/issues/issue-8460-const.rs | 12 +- src/test/ui/issues/issue-8460-const.stderr | 122 +++++------------- 9 files changed, 75 insertions(+), 141 deletions(-) delete mode 100644 src/test/ui/consts/issue-64059.stderr diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs index 091e68cd0669c..e4b186736e2a1 100644 --- a/src/librustc_mir/transform/const_prop.rs +++ b/src/librustc_mir/transform/const_prop.rs @@ -413,6 +413,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { // We check overflow in debug mode already // so should only check in release mode. if !oflo_check + && prim.layout.ty.is_signed() && prim.to_bits()? == (1 << (prim.layout.size.bits() - 1)) { throw_panic!(OverflowNeg) } diff --git a/src/test/ui/consts/const-err2.rs b/src/test/ui/consts/const-err2.rs index a5f685a159b39..cd6ac47bd92a8 100644 --- a/src/test/ui/consts/const-err2.rs +++ b/src/test/ui/consts/const-err2.rs @@ -5,6 +5,8 @@ #![feature(rustc_attrs)] #![allow(exceeding_bitshifts)] +// compile-flags: -C overflow-checks=on -O + #![deny(const_err)] fn black_box(_: T) { diff --git a/src/test/ui/consts/const-err2.stderr b/src/test/ui/consts/const-err2.stderr index 659c3afc618a9..ecfced7f0db8b 100644 --- a/src/test/ui/consts/const-err2.stderr +++ b/src/test/ui/consts/const-err2.stderr @@ -1,35 +1,35 @@ -error: this expression will panic at runtime - --> $DIR/const-err2.rs:15:13 +error: attempt to negate with overflow + --> $DIR/const-err2.rs:17:13 | LL | let a = -std::i8::MIN; - | ^^^^^^^^^^^^^ attempt to negate with overflow + | ^^^^^^^^^^^^^ | note: lint level defined here - --> $DIR/const-err2.rs:8:9 + --> $DIR/const-err2.rs:10:9 | LL | #![deny(const_err)] | ^^^^^^^^^ -error: this expression will panic at runtime - --> $DIR/const-err2.rs:17:13 +error: attempt to add with overflow + --> $DIR/const-err2.rs:19:13 | LL | let b = 200u8 + 200u8 + 200u8; - | ^^^^^^^^^^^^^ attempt to add with overflow + | ^^^^^^^^^^^^^ -error: this expression will panic at runtime - --> $DIR/const-err2.rs:19:13 +error: attempt to multiply with overflow + --> $DIR/const-err2.rs:21:13 | LL | let c = 200u8 * 4; - | ^^^^^^^^^ attempt to multiply with overflow + | ^^^^^^^^^ -error: this expression will panic at runtime - --> $DIR/const-err2.rs:21:13 +error: attempt to subtract with overflow + --> $DIR/const-err2.rs:23: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:23:14 + --> $DIR/const-err2.rs:25:14 | LL | let _e = [5u8][1]; | ^^^^^^^^ diff --git a/src/test/ui/consts/const-eval/promoted_errors.rs b/src/test/ui/consts/const-eval/promoted_errors.rs index cd989731452b3..7adb394144bdd 100644 --- a/src/test/ui/consts/const-eval/promoted_errors.rs +++ b/src/test/ui/consts/const-eval/promoted_errors.rs @@ -1,11 +1,12 @@ -// compile-flags: -O +// compile-flags: -C overflow-checks=on -O #![deny(const_err)] fn main() { println!("{}", 0u32 - 1); + //~^ ERROR attempt to subtract with overflow let _x = 0u32 - 1; - //~^ ERROR this expression will panic at runtime [const_err] + //~^ ERROR attempt to subtract with overflow println!("{}", 1/(1-1)); //~^ ERROR attempt to divide by zero [const_err] //~| ERROR reaching this expression at runtime will panic or abort [const_err] diff --git a/src/test/ui/consts/const-eval/promoted_errors.stderr b/src/test/ui/consts/const-eval/promoted_errors.stderr index 40d5c73e86679..fe63d0800dd7c 100644 --- a/src/test/ui/consts/const-eval/promoted_errors.stderr +++ b/src/test/ui/consts/const-eval/promoted_errors.stderr @@ -1,8 +1,8 @@ -error: this expression will panic at runtime - --> $DIR/promoted_errors.rs:7:14 +error: attempt to subtract with overflow + --> $DIR/promoted_errors.rs:6:20 | -LL | let _x = 0u32 - 1; - | ^^^^^^^^ attempt to subtract with overflow +LL | println!("{}", 0u32 - 1); + | ^^^^^^^^ | note: lint level defined here --> $DIR/promoted_errors.rs:3:9 @@ -10,53 +10,59 @@ note: lint level defined here LL | #![deny(const_err)] | ^^^^^^^^^ +error: attempt to subtract with overflow + --> $DIR/promoted_errors.rs:8:14 + | +LL | let _x = 0u32 - 1; + | ^^^^^^^^ + error: attempt to divide by zero - --> $DIR/promoted_errors.rs:9:20 + --> $DIR/promoted_errors.rs:10:20 | LL | println!("{}", 1/(1-1)); | ^^^^^^^ error: reaching this expression at runtime will panic or abort - --> $DIR/promoted_errors.rs:9:20 + --> $DIR/promoted_errors.rs:10:20 | LL | println!("{}", 1/(1-1)); | ^^^^^^^ attempt to divide by zero error: attempt to divide by zero - --> $DIR/promoted_errors.rs:12:14 + --> $DIR/promoted_errors.rs:13:14 | LL | let _x = 1/(1-1); | ^^^^^^^ error: this expression will panic at runtime - --> $DIR/promoted_errors.rs:12:14 + --> $DIR/promoted_errors.rs:13:14 | LL | let _x = 1/(1-1); | ^^^^^^^ attempt to divide by zero error: attempt to divide by zero - --> $DIR/promoted_errors.rs:15:20 + --> $DIR/promoted_errors.rs:16:20 | LL | println!("{}", 1/(false as u32)); | ^^^^^^^^^^^^^^^^ error: reaching this expression at runtime will panic or abort - --> $DIR/promoted_errors.rs:15:20 + --> $DIR/promoted_errors.rs:16:20 | LL | println!("{}", 1/(false as u32)); | ^^^^^^^^^^^^^^^^ attempt to divide by zero error: attempt to divide by zero - --> $DIR/promoted_errors.rs:18:14 + --> $DIR/promoted_errors.rs:19:14 | LL | let _x = 1/(false as u32); | ^^^^^^^^^^^^^^^^ error: this expression will panic at runtime - --> $DIR/promoted_errors.rs:18:14 + --> $DIR/promoted_errors.rs:19:14 | LL | let _x = 1/(false as u32); | ^^^^^^^^^^^^^^^^ attempt to divide by zero -error: aborting due to 9 previous errors +error: aborting due to 10 previous errors diff --git a/src/test/ui/consts/issue-64059.rs b/src/test/ui/consts/issue-64059.rs index 30b8744cb7fa7..38911c3dcf692 100644 --- a/src/test/ui/consts/issue-64059.rs +++ b/src/test/ui/consts/issue-64059.rs @@ -1,4 +1,6 @@ +// compile-flags: -C overflow-checks=on -O +// run-pass + fn main() { let _ = -(-0.0); - //~^ ERROR: this expression will panic at runtime } diff --git a/src/test/ui/consts/issue-64059.stderr b/src/test/ui/consts/issue-64059.stderr deleted file mode 100644 index 6f27653421bd6..0000000000000 --- a/src/test/ui/consts/issue-64059.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: this expression will panic at runtime - --> $DIR/issue-64059.rs:2:13 - | -LL | let _ = -(-0.0); - | ^^^^^^^ attempt to negate with overflow - | - = note: `#[deny(const_err)]` on by default - -error: aborting due to previous error - diff --git a/src/test/ui/issues/issue-8460-const.rs b/src/test/ui/issues/issue-8460-const.rs index 611d280f774c0..c3f53e3298b2b 100644 --- a/src/test/ui/issues/issue-8460-const.rs +++ b/src/test/ui/issues/issue-8460-const.rs @@ -1,3 +1,5 @@ +// compile-flags: -C overflow-checks=on -O + #![deny(const_err)] use std::{isize, i8, i16, i32, i64}; @@ -6,19 +8,14 @@ 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 assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err()); //~^ ERROR attempt to divide with overflow - //~| ERROR this expression will panic at runtime assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err()); //~^ ERROR attempt to divide with overflow - //~| ERROR this expression will panic at runtime assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err()); //~^ ERROR attempt to divide with overflow - //~| ERROR this expression will panic at runtime assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err()); //~^ ERROR attempt to divide with overflow - //~| ERROR this expression will panic at runtime assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); //~^ ERROR attempt to divide by zero //~| ERROR this expression will panic at runtime @@ -36,19 +33,14 @@ fn main() { //~| ERROR this expression will panic at runtime 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 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 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 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 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 assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err()); //~^ ERROR attempt to calculate the remainder with a divisor of zero //~| ERROR this expression will panic at runtime diff --git a/src/test/ui/issues/issue-8460-const.stderr b/src/test/ui/issues/issue-8460-const.stderr index 31b1da4f804ab..914323227ddd2 100644 --- a/src/test/ui/issues/issue-8460-const.stderr +++ b/src/test/ui/issues/issue-8460-const.stderr @@ -1,248 +1,188 @@ error: attempt to divide with overflow - --> $DIR/issue-8460-const.rs:7:36 + --> $DIR/issue-8460-const.rs:9:36 | LL | assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^^^ | note: lint level defined here - --> $DIR/issue-8460-const.rs:1:9 + --> $DIR/issue-8460-const.rs:3:9 | LL | #![deny(const_err)] | ^^^^^^^^^ -error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:7: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:10:36 + --> $DIR/issue-8460-const.rs:11:36 | LL | assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^ -error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:10: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:13:36 | LL | assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^ -error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:13: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:16:36 + --> $DIR/issue-8460-const.rs:15:36 | LL | assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^ -error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:16: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:19:36 + --> $DIR/issue-8460-const.rs:17:36 | LL | assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^ -error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:19:36 - | -LL | assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to divide with overflow - error: attempt to divide by zero - --> $DIR/issue-8460-const.rs:22:36 + --> $DIR/issue-8460-const.rs:19:36 | LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); | ^^^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:22:36 + --> $DIR/issue-8460-const.rs:19:36 | LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); | ^^^^^^^^^^ attempt to divide by zero error: attempt to divide by zero - --> $DIR/issue-8460-const.rs:25:36 + --> $DIR/issue-8460-const.rs:22:36 | LL | assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err()); | ^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:25:36 + --> $DIR/issue-8460-const.rs:22:36 | LL | assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err()); | ^^^^^^^ attempt to divide by zero error: attempt to divide by zero - --> $DIR/issue-8460-const.rs:28:36 + --> $DIR/issue-8460-const.rs:25:36 | LL | assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err()); | ^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:28:36 + --> $DIR/issue-8460-const.rs:25:36 | LL | assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err()); | ^^^^^^^^ attempt to divide by zero error: attempt to divide by zero - --> $DIR/issue-8460-const.rs:31:36 + --> $DIR/issue-8460-const.rs:28:36 | LL | assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err()); | ^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:31:36 + --> $DIR/issue-8460-const.rs:28:36 | LL | assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err()); | ^^^^^^^^ attempt to divide by zero error: attempt to divide by zero - --> $DIR/issue-8460-const.rs:34:36 + --> $DIR/issue-8460-const.rs:31:36 | LL | assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err()); | ^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:34:36 + --> $DIR/issue-8460-const.rs:31:36 | LL | assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err()); | ^^^^^^^^ attempt to divide by zero error: attempt to calculate the remainder with overflow - --> $DIR/issue-8460-const.rs:37:36 + --> $DIR/issue-8460-const.rs:34:36 | LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^^^ -error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:37: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:40:36 + --> $DIR/issue-8460-const.rs:36:36 | LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^ -error: this expression will panic at runtime - --> $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: attempt to calculate the remainder with overflow - --> $DIR/issue-8460-const.rs:43:36 + --> $DIR/issue-8460-const.rs:38:36 | LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^ -error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:43: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:46:36 + --> $DIR/issue-8460-const.rs:40:36 | LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^ -error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:46: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:49:36 + --> $DIR/issue-8460-const.rs:42:36 | LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^ -error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:49: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 a divisor of zero - --> $DIR/issue-8460-const.rs:52:36 + --> $DIR/issue-8460-const.rs:44:36 | LL | assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err()); | ^^^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:52:36 + --> $DIR/issue-8460-const.rs:44:36 | LL | assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err()); | ^^^^^^^^^^ attempt to calculate the remainder with a divisor of zero error: attempt to calculate the remainder with a divisor of zero - --> $DIR/issue-8460-const.rs:55:36 + --> $DIR/issue-8460-const.rs:47:36 | LL | assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err()); | ^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:55:36 + --> $DIR/issue-8460-const.rs:47:36 | LL | assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err()); | ^^^^^^^ attempt to calculate the remainder with a divisor of zero error: attempt to calculate the remainder with a divisor of zero - --> $DIR/issue-8460-const.rs:58:36 + --> $DIR/issue-8460-const.rs:50:36 | LL | assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err()); | ^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:58:36 + --> $DIR/issue-8460-const.rs:50:36 | LL | assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err()); | ^^^^^^^^ attempt to calculate the remainder with a divisor of zero error: attempt to calculate the remainder with a divisor of zero - --> $DIR/issue-8460-const.rs:61:36 + --> $DIR/issue-8460-const.rs:53:36 | LL | assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err()); | ^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:61:36 + --> $DIR/issue-8460-const.rs:53:36 | LL | assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err()); | ^^^^^^^^ attempt to calculate the remainder with a divisor of zero error: attempt to calculate the remainder with a divisor of zero - --> $DIR/issue-8460-const.rs:64:36 + --> $DIR/issue-8460-const.rs:56:36 | LL | assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err()); | ^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:64:36 + --> $DIR/issue-8460-const.rs:56:36 | LL | assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err()); | ^^^^^^^^ attempt to calculate the remainder with a divisor of zero -error: aborting due to 40 previous errors +error: aborting due to 30 previous errors From a937d8cdeb56ed72897ecf14469f89f18814554c Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Mon, 2 Sep 2019 05:01:39 +0900 Subject: [PATCH 6/7] Fix tests again --- src/test/ui/consts/const-err2.rs | 3 +- src/test/ui/consts/const-err2.stderr | 28 +-- src/test/ui/consts/const-err3.rs | 30 +++ src/test/ui/consts/const-err3.stderr | 38 ++++ .../ui/consts/const-eval/promoted_errors.rs | 5 +- .../consts/const-eval/promoted_errors.stderr | 32 ++- .../ui/consts/const-eval/promoted_errors2.rs | 22 ++ .../consts/const-eval/promoted_errors2.stderr | 68 +++++++ src/test/ui/consts/issue-64059-2.rs | 6 + src/test/ui/consts/issue-64059.rs | 1 - src/test/ui/issues/issue-8460-const.rs | 12 +- src/test/ui/issues/issue-8460-const.stderr | 122 +++++++++--- src/test/ui/issues/issue-8460-const2.rs | 59 ++++++ src/test/ui/issues/issue-8460-const2.stderr | 188 ++++++++++++++++++ 14 files changed, 542 insertions(+), 72 deletions(-) create mode 100644 src/test/ui/consts/const-err3.rs create mode 100644 src/test/ui/consts/const-err3.stderr create mode 100644 src/test/ui/consts/const-eval/promoted_errors2.rs create mode 100644 src/test/ui/consts/const-eval/promoted_errors2.stderr create mode 100644 src/test/ui/consts/issue-64059-2.rs create mode 100644 src/test/ui/issues/issue-8460-const2.rs create mode 100644 src/test/ui/issues/issue-8460-const2.stderr diff --git a/src/test/ui/consts/const-err2.rs b/src/test/ui/consts/const-err2.rs index cd6ac47bd92a8..ecbcc2a4b496f 100644 --- a/src/test/ui/consts/const-err2.rs +++ b/src/test/ui/consts/const-err2.rs @@ -5,7 +5,6 @@ #![feature(rustc_attrs)] #![allow(exceeding_bitshifts)] -// compile-flags: -C overflow-checks=on -O #![deny(const_err)] @@ -23,7 +22,7 @@ fn main() { let d = 42u8 - (42u8 + 1); //~^ ERROR const_err let _e = [5u8][1]; - //~^ ERROR const_err + //~^ ERROR index out of bounds black_box(a); black_box(b); black_box(c); diff --git a/src/test/ui/consts/const-err2.stderr b/src/test/ui/consts/const-err2.stderr index ecfced7f0db8b..1d84d44dc27b3 100644 --- a/src/test/ui/consts/const-err2.stderr +++ b/src/test/ui/consts/const-err2.stderr @@ -1,35 +1,35 @@ -error: attempt to negate with overflow - --> $DIR/const-err2.rs:17:13 +error: this expression will panic at runtime + --> $DIR/const-err2.rs:16:13 | LL | let a = -std::i8::MIN; - | ^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^ attempt to negate with overflow | note: lint level defined here - --> $DIR/const-err2.rs:10:9 + --> $DIR/const-err2.rs:9:9 | LL | #![deny(const_err)] | ^^^^^^^^^ -error: attempt to add with overflow - --> $DIR/const-err2.rs:19:13 +error: this expression will panic at runtime + --> $DIR/const-err2.rs:18:13 | LL | let b = 200u8 + 200u8 + 200u8; - | ^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^ attempt to add with overflow -error: attempt to multiply with overflow - --> $DIR/const-err2.rs:21:13 +error: this expression will panic at runtime + --> $DIR/const-err2.rs:20:13 | LL | let c = 200u8 * 4; - | ^^^^^^^^^ + | ^^^^^^^^^ attempt to multiply with overflow -error: attempt to subtract with overflow - --> $DIR/const-err2.rs:23:13 +error: this expression will panic at runtime + --> $DIR/const-err2.rs:22: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:25:14 + --> $DIR/const-err2.rs:24:14 | LL | let _e = [5u8][1]; | ^^^^^^^^ diff --git a/src/test/ui/consts/const-err3.rs b/src/test/ui/consts/const-err3.rs new file mode 100644 index 0000000000000..a9cf04cda7a5a --- /dev/null +++ b/src/test/ui/consts/const-err3.rs @@ -0,0 +1,30 @@ +// needed because negating int::MIN will behave differently between +// optimized compilation and unoptimized compilation and thus would +// lead to different lints being emitted +// 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 b = 200u8 + 200u8 + 200u8; + //~^ 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(b); + black_box(c); + black_box(d); +} diff --git a/src/test/ui/consts/const-err3.stderr b/src/test/ui/consts/const-err3.stderr new file mode 100644 index 0000000000000..0602707be7040 --- /dev/null +++ b/src/test/ui/consts/const-err3.stderr @@ -0,0 +1,38 @@ +error: attempt to negate with overflow + --> $DIR/const-err3.rs:16:13 + | +LL | let a = -std::i8::MIN; + | ^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/const-err3.rs:9:9 + | +LL | #![deny(const_err)] + | ^^^^^^^^^ + +error: attempt to add with overflow + --> $DIR/const-err3.rs:18:13 + | +LL | let b = 200u8 + 200u8 + 200u8; + | ^^^^^^^^^^^^^ + +error: attempt to multiply with overflow + --> $DIR/const-err3.rs:20:13 + | +LL | let c = 200u8 * 4; + | ^^^^^^^^^ + +error: attempt to subtract with overflow + --> $DIR/const-err3.rs:22: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:24:14 + | +LL | let _e = [5u8][1]; + | ^^^^^^^^ + +error: aborting due to 5 previous errors + diff --git a/src/test/ui/consts/const-eval/promoted_errors.rs b/src/test/ui/consts/const-eval/promoted_errors.rs index 7adb394144bdd..45941398f4b66 100644 --- a/src/test/ui/consts/const-eval/promoted_errors.rs +++ b/src/test/ui/consts/const-eval/promoted_errors.rs @@ -1,12 +1,11 @@ -// compile-flags: -C overflow-checks=on -O +// compile-flags: -O #![deny(const_err)] fn main() { println!("{}", 0u32 - 1); - //~^ ERROR attempt to subtract with overflow let _x = 0u32 - 1; - //~^ ERROR attempt to subtract with overflow + //~^ ERROR const_err println!("{}", 1/(1-1)); //~^ ERROR attempt to divide by zero [const_err] //~| ERROR reaching this expression at runtime will panic or abort [const_err] diff --git a/src/test/ui/consts/const-eval/promoted_errors.stderr b/src/test/ui/consts/const-eval/promoted_errors.stderr index fe63d0800dd7c..40d5c73e86679 100644 --- a/src/test/ui/consts/const-eval/promoted_errors.stderr +++ b/src/test/ui/consts/const-eval/promoted_errors.stderr @@ -1,8 +1,8 @@ -error: attempt to subtract with overflow - --> $DIR/promoted_errors.rs:6:20 +error: this expression will panic at runtime + --> $DIR/promoted_errors.rs:7:14 | -LL | println!("{}", 0u32 - 1); - | ^^^^^^^^ +LL | let _x = 0u32 - 1; + | ^^^^^^^^ attempt to subtract with overflow | note: lint level defined here --> $DIR/promoted_errors.rs:3:9 @@ -10,59 +10,53 @@ note: lint level defined here LL | #![deny(const_err)] | ^^^^^^^^^ -error: attempt to subtract with overflow - --> $DIR/promoted_errors.rs:8:14 - | -LL | let _x = 0u32 - 1; - | ^^^^^^^^ - error: attempt to divide by zero - --> $DIR/promoted_errors.rs:10:20 + --> $DIR/promoted_errors.rs:9:20 | LL | println!("{}", 1/(1-1)); | ^^^^^^^ error: reaching this expression at runtime will panic or abort - --> $DIR/promoted_errors.rs:10:20 + --> $DIR/promoted_errors.rs:9:20 | LL | println!("{}", 1/(1-1)); | ^^^^^^^ attempt to divide by zero error: attempt to divide by zero - --> $DIR/promoted_errors.rs:13:14 + --> $DIR/promoted_errors.rs:12:14 | LL | let _x = 1/(1-1); | ^^^^^^^ error: this expression will panic at runtime - --> $DIR/promoted_errors.rs:13:14 + --> $DIR/promoted_errors.rs:12:14 | LL | let _x = 1/(1-1); | ^^^^^^^ attempt to divide by zero error: attempt to divide by zero - --> $DIR/promoted_errors.rs:16:20 + --> $DIR/promoted_errors.rs:15:20 | LL | println!("{}", 1/(false as u32)); | ^^^^^^^^^^^^^^^^ error: reaching this expression at runtime will panic or abort - --> $DIR/promoted_errors.rs:16:20 + --> $DIR/promoted_errors.rs:15:20 | LL | println!("{}", 1/(false as u32)); | ^^^^^^^^^^^^^^^^ attempt to divide by zero error: attempt to divide by zero - --> $DIR/promoted_errors.rs:19:14 + --> $DIR/promoted_errors.rs:18:14 | LL | let _x = 1/(false as u32); | ^^^^^^^^^^^^^^^^ error: this expression will panic at runtime - --> $DIR/promoted_errors.rs:19:14 + --> $DIR/promoted_errors.rs:18:14 | LL | let _x = 1/(false as u32); | ^^^^^^^^^^^^^^^^ attempt to divide by zero -error: aborting due to 10 previous errors +error: aborting due to 9 previous errors diff --git a/src/test/ui/consts/const-eval/promoted_errors2.rs b/src/test/ui/consts/const-eval/promoted_errors2.rs new file mode 100644 index 0000000000000..7adb394144bdd --- /dev/null +++ b/src/test/ui/consts/const-eval/promoted_errors2.rs @@ -0,0 +1,22 @@ +// compile-flags: -C overflow-checks=on -O + +#![deny(const_err)] + +fn main() { + println!("{}", 0u32 - 1); + //~^ ERROR attempt to subtract with overflow + let _x = 0u32 - 1; + //~^ ERROR attempt to subtract with overflow + println!("{}", 1/(1-1)); + //~^ ERROR attempt to divide by zero [const_err] + //~| ERROR reaching this expression at runtime will panic or abort [const_err] + let _x = 1/(1-1); + //~^ ERROR const_err + //~| ERROR const_err + println!("{}", 1/(false as u32)); + //~^ ERROR attempt to divide by zero [const_err] + //~| ERROR reaching this expression at runtime will panic or abort [const_err] + let _x = 1/(false as u32); + //~^ ERROR const_err + //~| ERROR const_err +} diff --git a/src/test/ui/consts/const-eval/promoted_errors2.stderr b/src/test/ui/consts/const-eval/promoted_errors2.stderr new file mode 100644 index 0000000000000..2819e6e8fdbe0 --- /dev/null +++ b/src/test/ui/consts/const-eval/promoted_errors2.stderr @@ -0,0 +1,68 @@ +error: attempt to subtract with overflow + --> $DIR/promoted_errors2.rs:6:20 + | +LL | println!("{}", 0u32 - 1); + | ^^^^^^^^ + | +note: lint level defined here + --> $DIR/promoted_errors2.rs:3:9 + | +LL | #![deny(const_err)] + | ^^^^^^^^^ + +error: attempt to subtract with overflow + --> $DIR/promoted_errors2.rs:8:14 + | +LL | let _x = 0u32 - 1; + | ^^^^^^^^ + +error: attempt to divide by zero + --> $DIR/promoted_errors2.rs:10:20 + | +LL | println!("{}", 1/(1-1)); + | ^^^^^^^ + +error: reaching this expression at runtime will panic or abort + --> $DIR/promoted_errors2.rs:10:20 + | +LL | println!("{}", 1/(1-1)); + | ^^^^^^^ attempt to divide by zero + +error: attempt to divide by zero + --> $DIR/promoted_errors2.rs:13:14 + | +LL | let _x = 1/(1-1); + | ^^^^^^^ + +error: this expression will panic at runtime + --> $DIR/promoted_errors2.rs:13:14 + | +LL | let _x = 1/(1-1); + | ^^^^^^^ attempt to divide by zero + +error: attempt to divide by zero + --> $DIR/promoted_errors2.rs:16:20 + | +LL | println!("{}", 1/(false as u32)); + | ^^^^^^^^^^^^^^^^ + +error: reaching this expression at runtime will panic or abort + --> $DIR/promoted_errors2.rs:16:20 + | +LL | println!("{}", 1/(false as u32)); + | ^^^^^^^^^^^^^^^^ attempt to divide by zero + +error: attempt to divide by zero + --> $DIR/promoted_errors2.rs:19:14 + | +LL | let _x = 1/(false as u32); + | ^^^^^^^^^^^^^^^^ + +error: this expression will panic at runtime + --> $DIR/promoted_errors2.rs:19:14 + | +LL | let _x = 1/(false as u32); + | ^^^^^^^^^^^^^^^^ attempt to divide by zero + +error: aborting due to 10 previous errors + diff --git a/src/test/ui/consts/issue-64059-2.rs b/src/test/ui/consts/issue-64059-2.rs new file mode 100644 index 0000000000000..38911c3dcf692 --- /dev/null +++ b/src/test/ui/consts/issue-64059-2.rs @@ -0,0 +1,6 @@ +// compile-flags: -C overflow-checks=on -O +// run-pass + +fn main() { + let _ = -(-0.0); +} diff --git a/src/test/ui/consts/issue-64059.rs b/src/test/ui/consts/issue-64059.rs index 38911c3dcf692..c4c895fef66cf 100644 --- a/src/test/ui/consts/issue-64059.rs +++ b/src/test/ui/consts/issue-64059.rs @@ -1,4 +1,3 @@ -// compile-flags: -C overflow-checks=on -O // run-pass fn main() { diff --git a/src/test/ui/issues/issue-8460-const.rs b/src/test/ui/issues/issue-8460-const.rs index c3f53e3298b2b..611d280f774c0 100644 --- a/src/test/ui/issues/issue-8460-const.rs +++ b/src/test/ui/issues/issue-8460-const.rs @@ -1,5 +1,3 @@ -// compile-flags: -C overflow-checks=on -O - #![deny(const_err)] use std::{isize, i8, i16, i32, i64}; @@ -8,14 +6,19 @@ 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 assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err()); //~^ ERROR attempt to divide with overflow + //~| ERROR this expression will panic at runtime assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err()); //~^ ERROR attempt to divide with overflow + //~| ERROR this expression will panic at runtime assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err()); //~^ ERROR attempt to divide with overflow + //~| ERROR this expression will panic at runtime assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err()); //~^ ERROR attempt to divide with overflow + //~| ERROR this expression will panic at runtime assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); //~^ ERROR attempt to divide by zero //~| ERROR this expression will panic at runtime @@ -33,14 +36,19 @@ fn main() { //~| ERROR this expression will panic at runtime 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 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 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 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 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 assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err()); //~^ ERROR attempt to calculate the remainder with a divisor of zero //~| ERROR this expression will panic at runtime diff --git a/src/test/ui/issues/issue-8460-const.stderr b/src/test/ui/issues/issue-8460-const.stderr index 914323227ddd2..31b1da4f804ab 100644 --- a/src/test/ui/issues/issue-8460-const.stderr +++ b/src/test/ui/issues/issue-8460-const.stderr @@ -1,188 +1,248 @@ error: attempt to divide with overflow - --> $DIR/issue-8460-const.rs:9:36 + --> $DIR/issue-8460-const.rs:7:36 | LL | assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^^^ | note: lint level defined here - --> $DIR/issue-8460-const.rs:3:9 + --> $DIR/issue-8460-const.rs:1:9 | LL | #![deny(const_err)] | ^^^^^^^^^ +error: this expression will panic at runtime + --> $DIR/issue-8460-const.rs:7: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:11:36 + --> $DIR/issue-8460-const.rs:10:36 | LL | assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^ +error: this expression will panic at runtime + --> $DIR/issue-8460-const.rs:10: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:13:36 | LL | assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^ +error: this expression will panic at runtime + --> $DIR/issue-8460-const.rs:13: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:15:36 + --> $DIR/issue-8460-const.rs:16:36 | LL | assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^ +error: this expression will panic at runtime + --> $DIR/issue-8460-const.rs:16: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:17:36 + --> $DIR/issue-8460-const.rs:19:36 | LL | assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^ -error: attempt to divide by zero +error: this expression will panic at runtime --> $DIR/issue-8460-const.rs:19:36 | +LL | assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err()); + | ^^^^^^^^^^^^^ attempt to divide with overflow + +error: attempt to divide by zero + --> $DIR/issue-8460-const.rs:22:36 + | LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); | ^^^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:19:36 + --> $DIR/issue-8460-const.rs:22:36 | LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); | ^^^^^^^^^^ attempt to divide by zero error: attempt to divide by zero - --> $DIR/issue-8460-const.rs:22:36 + --> $DIR/issue-8460-const.rs:25:36 | LL | assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err()); | ^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:22:36 + --> $DIR/issue-8460-const.rs:25:36 | LL | assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err()); | ^^^^^^^ attempt to divide by zero error: attempt to divide by zero - --> $DIR/issue-8460-const.rs:25:36 + --> $DIR/issue-8460-const.rs:28:36 | LL | assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err()); | ^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:25:36 + --> $DIR/issue-8460-const.rs:28:36 | LL | assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err()); | ^^^^^^^^ attempt to divide by zero error: attempt to divide by zero - --> $DIR/issue-8460-const.rs:28:36 + --> $DIR/issue-8460-const.rs:31:36 | LL | assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err()); | ^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:28:36 + --> $DIR/issue-8460-const.rs:31:36 | LL | assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err()); | ^^^^^^^^ attempt to divide by zero error: attempt to divide by zero - --> $DIR/issue-8460-const.rs:31:36 + --> $DIR/issue-8460-const.rs:34:36 | LL | assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err()); | ^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:31:36 + --> $DIR/issue-8460-const.rs:34:36 | LL | assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err()); | ^^^^^^^^ attempt to divide by zero error: attempt to calculate the remainder with overflow - --> $DIR/issue-8460-const.rs:34:36 + --> $DIR/issue-8460-const.rs:37:36 | LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^^^ +error: this expression will panic at runtime + --> $DIR/issue-8460-const.rs:37: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:36:36 + --> $DIR/issue-8460-const.rs:40:36 | LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^ +error: this expression will panic at runtime + --> $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: attempt to calculate the remainder with overflow - --> $DIR/issue-8460-const.rs:38:36 + --> $DIR/issue-8460-const.rs:43:36 | LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^ +error: this expression will panic at runtime + --> $DIR/issue-8460-const.rs:43: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:40:36 + --> $DIR/issue-8460-const.rs:46:36 | LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^ +error: this expression will panic at runtime + --> $DIR/issue-8460-const.rs:46: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:42:36 + --> $DIR/issue-8460-const.rs:49:36 | LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^ +error: this expression will panic at runtime + --> $DIR/issue-8460-const.rs:49: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 a divisor of zero - --> $DIR/issue-8460-const.rs:44:36 + --> $DIR/issue-8460-const.rs:52:36 | LL | assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err()); | ^^^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:44:36 + --> $DIR/issue-8460-const.rs:52:36 | LL | assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err()); | ^^^^^^^^^^ attempt to calculate the remainder with a divisor of zero error: attempt to calculate the remainder with a divisor of zero - --> $DIR/issue-8460-const.rs:47:36 + --> $DIR/issue-8460-const.rs:55:36 | LL | assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err()); | ^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:47:36 + --> $DIR/issue-8460-const.rs:55:36 | LL | assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err()); | ^^^^^^^ attempt to calculate the remainder with a divisor of zero error: attempt to calculate the remainder with a divisor of zero - --> $DIR/issue-8460-const.rs:50:36 + --> $DIR/issue-8460-const.rs:58:36 | LL | assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err()); | ^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:50:36 + --> $DIR/issue-8460-const.rs:58:36 | LL | assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err()); | ^^^^^^^^ attempt to calculate the remainder with a divisor of zero error: attempt to calculate the remainder with a divisor of zero - --> $DIR/issue-8460-const.rs:53:36 + --> $DIR/issue-8460-const.rs:61:36 | LL | assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err()); | ^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:53:36 + --> $DIR/issue-8460-const.rs:61:36 | LL | assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err()); | ^^^^^^^^ attempt to calculate the remainder with a divisor of zero error: attempt to calculate the remainder with a divisor of zero - --> $DIR/issue-8460-const.rs:56:36 + --> $DIR/issue-8460-const.rs:64:36 | LL | assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err()); | ^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:56:36 + --> $DIR/issue-8460-const.rs:64:36 | LL | assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err()); | ^^^^^^^^ attempt to calculate the remainder with a divisor of zero -error: aborting due to 30 previous errors +error: aborting due to 40 previous errors diff --git a/src/test/ui/issues/issue-8460-const2.rs b/src/test/ui/issues/issue-8460-const2.rs new file mode 100644 index 0000000000000..c3f53e3298b2b --- /dev/null +++ b/src/test/ui/issues/issue-8460-const2.rs @@ -0,0 +1,59 @@ +// compile-flags: -C overflow-checks=on -O + +#![deny(const_err)] + +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 + 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|| { 1isize / 0; }).join().is_err()); + //~^ ERROR attempt to divide by zero + //~| ERROR this expression will panic at runtime + assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err()); + //~^ ERROR attempt to divide by zero + //~| ERROR this expression will panic at runtime + assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err()); + //~^ ERROR attempt to divide by zero + //~| ERROR this expression will panic at runtime + assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err()); + //~^ ERROR attempt to divide by zero + //~| ERROR this expression will panic at runtime + assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err()); + //~^ ERROR attempt to divide by zero + //~| ERROR this expression will panic at runtime + 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|| { 1isize % 0; }).join().is_err()); + //~^ ERROR attempt to calculate the remainder with a divisor of zero + //~| ERROR this expression will panic at runtime + assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err()); + //~^ ERROR attempt to calculate the remainder with a divisor of zero + //~| ERROR this expression will panic at runtime + assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err()); + //~^ ERROR attempt to calculate the remainder with a divisor of zero + //~| ERROR this expression will panic at runtime + assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err()); + //~^ ERROR attempt to calculate the remainder with a divisor of zero + //~| ERROR this expression will panic at runtime + assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err()); + //~^ ERROR attempt to calculate the remainder with a divisor of zero + //~| ERROR this expression will panic at runtime +} diff --git a/src/test/ui/issues/issue-8460-const2.stderr b/src/test/ui/issues/issue-8460-const2.stderr new file mode 100644 index 0000000000000..b688ec1367794 --- /dev/null +++ b/src/test/ui/issues/issue-8460-const2.stderr @@ -0,0 +1,188 @@ +error: attempt to divide with overflow + --> $DIR/issue-8460-const2.rs:9:36 + | +LL | assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err()); + | ^^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/issue-8460-const2.rs:3:9 + | +LL | #![deny(const_err)] + | ^^^^^^^^^ + +error: attempt to divide with overflow + --> $DIR/issue-8460-const2.rs:11:36 + | +LL | assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err()); + | ^^^^^^^^^^^^ + +error: attempt to divide with overflow + --> $DIR/issue-8460-const2.rs:13:36 + | +LL | assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err()); + | ^^^^^^^^^^^^^ + +error: attempt to divide with overflow + --> $DIR/issue-8460-const2.rs:15:36 + | +LL | assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err()); + | ^^^^^^^^^^^^^ + +error: attempt to divide with overflow + --> $DIR/issue-8460-const2.rs:17:36 + | +LL | assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err()); + | ^^^^^^^^^^^^^ + +error: attempt to divide by zero + --> $DIR/issue-8460-const2.rs:19:36 + | +LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); + | ^^^^^^^^^^ + +error: this expression will panic at runtime + --> $DIR/issue-8460-const2.rs:19:36 + | +LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); + | ^^^^^^^^^^ attempt to divide by zero + +error: attempt to divide by zero + --> $DIR/issue-8460-const2.rs:22:36 + | +LL | assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err()); + | ^^^^^^^ + +error: this expression will panic at runtime + --> $DIR/issue-8460-const2.rs:22:36 + | +LL | assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err()); + | ^^^^^^^ attempt to divide by zero + +error: attempt to divide by zero + --> $DIR/issue-8460-const2.rs:25:36 + | +LL | assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err()); + | ^^^^^^^^ + +error: this expression will panic at runtime + --> $DIR/issue-8460-const2.rs:25:36 + | +LL | assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err()); + | ^^^^^^^^ attempt to divide by zero + +error: attempt to divide by zero + --> $DIR/issue-8460-const2.rs:28:36 + | +LL | assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err()); + | ^^^^^^^^ + +error: this expression will panic at runtime + --> $DIR/issue-8460-const2.rs:28:36 + | +LL | assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err()); + | ^^^^^^^^ attempt to divide by zero + +error: attempt to divide by zero + --> $DIR/issue-8460-const2.rs:31:36 + | +LL | assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err()); + | ^^^^^^^^ + +error: this expression will panic at runtime + --> $DIR/issue-8460-const2.rs:31:36 + | +LL | assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err()); + | ^^^^^^^^ attempt to divide by zero + +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 a divisor of zero + --> $DIR/issue-8460-const2.rs:44:36 + | +LL | assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err()); + | ^^^^^^^^^^ + +error: this expression will panic at runtime + --> $DIR/issue-8460-const2.rs:44:36 + | +LL | assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err()); + | ^^^^^^^^^^ attempt to calculate the remainder with a divisor of zero + +error: attempt to calculate the remainder with a divisor of zero + --> $DIR/issue-8460-const2.rs:47:36 + | +LL | assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err()); + | ^^^^^^^ + +error: this expression will panic at runtime + --> $DIR/issue-8460-const2.rs:47:36 + | +LL | assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err()); + | ^^^^^^^ attempt to calculate the remainder with a divisor of zero + +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: this expression will panic at runtime + --> $DIR/issue-8460-const2.rs:50:36 + | +LL | assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err()); + | ^^^^^^^^ attempt to calculate the remainder with a divisor of zero + +error: attempt to calculate the remainder with a divisor of zero + --> $DIR/issue-8460-const2.rs:53:36 + | +LL | assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err()); + | ^^^^^^^^ + +error: this expression will panic at runtime + --> $DIR/issue-8460-const2.rs:53:36 + | +LL | assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err()); + | ^^^^^^^^ attempt to calculate the remainder with a divisor of zero + +error: attempt to calculate the remainder with a divisor of zero + --> $DIR/issue-8460-const2.rs:56:36 + | +LL | assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err()); + | ^^^^^^^^ + +error: this expression will panic at runtime + --> $DIR/issue-8460-const2.rs:56:36 + | +LL | assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err()); + | ^^^^^^^^ attempt to calculate the remainder with a divisor of zero + +error: aborting due to 30 previous errors + From 41deb835498391623388555b8d44fa358c804be7 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Wed, 4 Sep 2019 18:32:00 +0900 Subject: [PATCH 7/7] Add compile flag --- src/test/ui/issues/issue-8460-const.rs | 2 + src/test/ui/issues/issue-8460-const.stderr | 82 +++++++++++----------- 2 files changed, 43 insertions(+), 41 deletions(-) diff --git a/src/test/ui/issues/issue-8460-const.rs b/src/test/ui/issues/issue-8460-const.rs index 611d280f774c0..4637814b277a4 100644 --- a/src/test/ui/issues/issue-8460-const.rs +++ b/src/test/ui/issues/issue-8460-const.rs @@ -1,3 +1,5 @@ +// compile-flags: -O + #![deny(const_err)] use std::{isize, i8, i16, i32, i64}; diff --git a/src/test/ui/issues/issue-8460-const.stderr b/src/test/ui/issues/issue-8460-const.stderr index 31b1da4f804ab..7e5a22e651ee5 100644 --- a/src/test/ui/issues/issue-8460-const.stderr +++ b/src/test/ui/issues/issue-8460-const.stderr @@ -1,245 +1,245 @@ error: attempt to divide with overflow - --> $DIR/issue-8460-const.rs:7:36 + --> $DIR/issue-8460-const.rs:9:36 | LL | assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^^^ | note: lint level defined here - --> $DIR/issue-8460-const.rs:1:9 + --> $DIR/issue-8460-const.rs:3:9 | LL | #![deny(const_err)] | ^^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:7:36 + --> $DIR/issue-8460-const.rs:9: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:10:36 + --> $DIR/issue-8460-const.rs:12:36 | LL | assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:10:36 + --> $DIR/issue-8460-const.rs:12: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:13:36 + --> $DIR/issue-8460-const.rs:15:36 | LL | assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:13:36 + --> $DIR/issue-8460-const.rs:15: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:16:36 + --> $DIR/issue-8460-const.rs:18:36 | LL | assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:16:36 + --> $DIR/issue-8460-const.rs:18: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:19:36 + --> $DIR/issue-8460-const.rs:21:36 | LL | assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:19:36 + --> $DIR/issue-8460-const.rs:21:36 | LL | assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^ attempt to divide with overflow error: attempt to divide by zero - --> $DIR/issue-8460-const.rs:22:36 + --> $DIR/issue-8460-const.rs:24:36 | LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); | ^^^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:22:36 + --> $DIR/issue-8460-const.rs:24:36 | LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); | ^^^^^^^^^^ attempt to divide by zero error: attempt to divide by zero - --> $DIR/issue-8460-const.rs:25:36 + --> $DIR/issue-8460-const.rs:27:36 | LL | assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err()); | ^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:25:36 + --> $DIR/issue-8460-const.rs:27:36 | LL | assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err()); | ^^^^^^^ attempt to divide by zero error: attempt to divide by zero - --> $DIR/issue-8460-const.rs:28:36 + --> $DIR/issue-8460-const.rs:30:36 | LL | assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err()); | ^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:28:36 + --> $DIR/issue-8460-const.rs:30:36 | LL | assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err()); | ^^^^^^^^ attempt to divide by zero error: attempt to divide by zero - --> $DIR/issue-8460-const.rs:31:36 + --> $DIR/issue-8460-const.rs:33:36 | LL | assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err()); | ^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:31:36 + --> $DIR/issue-8460-const.rs:33:36 | LL | assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err()); | ^^^^^^^^ attempt to divide by zero error: attempt to divide by zero - --> $DIR/issue-8460-const.rs:34:36 + --> $DIR/issue-8460-const.rs:36:36 | LL | assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err()); | ^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:34:36 + --> $DIR/issue-8460-const.rs:36:36 | LL | assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err()); | ^^^^^^^^ attempt to divide by zero error: attempt to calculate the remainder with overflow - --> $DIR/issue-8460-const.rs:37:36 + --> $DIR/issue-8460-const.rs:39:36 | LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:37:36 + --> $DIR/issue-8460-const.rs:39: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:40:36 + --> $DIR/issue-8460-const.rs:42:36 | LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:40:36 + --> $DIR/issue-8460-const.rs:42: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:43:36 + --> $DIR/issue-8460-const.rs:45:36 | LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:43:36 + --> $DIR/issue-8460-const.rs:45: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:46:36 + --> $DIR/issue-8460-const.rs:48:36 | LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:46:36 + --> $DIR/issue-8460-const.rs:48: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:49:36 + --> $DIR/issue-8460-const.rs:51:36 | LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:49:36 + --> $DIR/issue-8460-const.rs:51: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 a divisor of zero - --> $DIR/issue-8460-const.rs:52:36 + --> $DIR/issue-8460-const.rs:54:36 | LL | assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err()); | ^^^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:52:36 + --> $DIR/issue-8460-const.rs:54:36 | LL | assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err()); | ^^^^^^^^^^ attempt to calculate the remainder with a divisor of zero error: attempt to calculate the remainder with a divisor of zero - --> $DIR/issue-8460-const.rs:55:36 + --> $DIR/issue-8460-const.rs:57:36 | LL | assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err()); | ^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:55:36 + --> $DIR/issue-8460-const.rs:57:36 | LL | assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err()); | ^^^^^^^ attempt to calculate the remainder with a divisor of zero error: attempt to calculate the remainder with a divisor of zero - --> $DIR/issue-8460-const.rs:58:36 + --> $DIR/issue-8460-const.rs:60:36 | LL | assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err()); | ^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:58:36 + --> $DIR/issue-8460-const.rs:60:36 | LL | assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err()); | ^^^^^^^^ attempt to calculate the remainder with a divisor of zero error: attempt to calculate the remainder with a divisor of zero - --> $DIR/issue-8460-const.rs:61:36 + --> $DIR/issue-8460-const.rs:63:36 | LL | assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err()); | ^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:61:36 + --> $DIR/issue-8460-const.rs:63:36 | LL | assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err()); | ^^^^^^^^ attempt to calculate the remainder with a divisor of zero error: attempt to calculate the remainder with a divisor of zero - --> $DIR/issue-8460-const.rs:64:36 + --> $DIR/issue-8460-const.rs:66:36 | LL | assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err()); | ^^^^^^^^ error: this expression will panic at runtime - --> $DIR/issue-8460-const.rs:64:36 + --> $DIR/issue-8460-const.rs:66:36 | LL | assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err()); | ^^^^^^^^ attempt to calculate the remainder with a divisor of zero