Auto merge of #66927 - RalfJung:engines-dont-panic, r=oli-obk

Miri core engine: use throw_ub instead of throw_panic

See https://github.com/rust-lang/rust/issues/66902 for context: panicking is not really an "interpreter error", but just part of a normal Rust execution. This is a first step towards removing the `InterpError::Panic` variant: the core Miri engine does not use it any more.

ConstProp and ConstEval still use it, though. This will be addressed in future PRs.

From what I can tell, all the error messages this removes are actually duplicates.

r? @oli-obk @wesleywiser
This commit is contained in:
bors 2019-12-07 14:46:30 +00:00
commit 5c5c8eb864
22 changed files with 104 additions and 294 deletions

View File

@ -370,6 +370,14 @@ pub enum UndefinedBehaviorInfo {
Unreachable, Unreachable,
/// An enum discriminant was set to a value which was outside the range of valid values. /// An enum discriminant was set to a value which was outside the range of valid values.
InvalidDiscriminant(ScalarMaybeUndef), InvalidDiscriminant(ScalarMaybeUndef),
/// A slice/array index projection went out-of-bounds.
BoundsCheckFailed { len: u64, index: u64 },
/// Something was divided by 0 (x / 0).
DivisionByZero,
/// Something was "remainded" by 0 (x % 0).
RemainderByZero,
/// Overflowing inbounds pointer arithmetic.
PointerArithOverflow,
} }
impl fmt::Debug for UndefinedBehaviorInfo { impl fmt::Debug for UndefinedBehaviorInfo {
@ -379,9 +387,18 @@ impl fmt::Debug for UndefinedBehaviorInfo {
Ub(msg) | UbExperimental(msg) => Ub(msg) | UbExperimental(msg) =>
write!(f, "{}", msg), write!(f, "{}", msg),
Unreachable => Unreachable =>
write!(f, "entered unreachable code"), write!(f, "entering unreachable code"),
InvalidDiscriminant(val) => InvalidDiscriminant(val) =>
write!(f, "encountered invalid enum discriminant {}", val), write!(f, "encountering invalid enum discriminant {}", val),
BoundsCheckFailed { ref len, ref index } =>
write!(f, "indexing out of bounds: the len is {:?} but the index is {:?}",
len, index),
DivisionByZero =>
write!(f, "dividing by zero"),
RemainderByZero =>
write!(f, "calculating the remainder with a divisor of zero"),
PointerArithOverflow =>
write!(f, "overflowing in-bounds pointer arithmetic"),
} }
} }
} }

View File

@ -1,6 +1,5 @@
use super::{AllocId, InterpResult}; use super::{AllocId, InterpResult};
use crate::mir;
use crate::ty::layout::{self, HasDataLayout, Size}; use crate::ty::layout::{self, HasDataLayout, Size};
use rustc_macros::HashStable; use rustc_macros::HashStable;
@ -88,13 +87,13 @@ pub trait PointerArithmetic: layout::HasDataLayout {
#[inline] #[inline]
fn offset<'tcx>(&self, val: u64, i: u64) -> InterpResult<'tcx, u64> { fn offset<'tcx>(&self, val: u64, i: u64) -> InterpResult<'tcx, u64> {
let (res, over) = self.overflowing_offset(val, i); let (res, over) = self.overflowing_offset(val, i);
if over { throw_panic!(Overflow(mir::BinOp::Add)) } else { Ok(res) } if over { throw_ub!(PointerArithOverflow) } else { Ok(res) }
} }
#[inline] #[inline]
fn signed_offset<'tcx>(&self, val: u64, i: i64) -> InterpResult<'tcx, u64> { fn signed_offset<'tcx>(&self, val: u64, i: i64) -> InterpResult<'tcx, u64> {
let (res, over) = self.overflowing_signed_offset(val, i128::from(i)); let (res, over) = self.overflowing_signed_offset(val, i128::from(i));
if over { throw_panic!(Overflow(mir::BinOp::Add)) } else { Ok(res) } if over { throw_ub!(PointerArithOverflow) } else { Ok(res) }
} }
} }

View File

@ -177,8 +177,8 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
return Ok((Scalar::from_bool(op(&l, &r)), false, self.tcx.types.bool)); return Ok((Scalar::from_bool(op(&l, &r)), false, self.tcx.types.bool));
} }
let op: Option<fn(i128, i128) -> (i128, bool)> = match bin_op { let op: Option<fn(i128, i128) -> (i128, bool)> = match bin_op {
Div if r == 0 => throw_panic!(DivisionByZero), Div if r == 0 => throw_ub!(DivisionByZero),
Rem if r == 0 => throw_panic!(RemainderByZero), Rem if r == 0 => throw_ub!(RemainderByZero),
Div => Some(i128::overflowing_div), Div => Some(i128::overflowing_div),
Rem => Some(i128::overflowing_rem), Rem => Some(i128::overflowing_rem),
Add => Some(i128::overflowing_add), Add => Some(i128::overflowing_add),
@ -234,8 +234,8 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
Add => u128::overflowing_add, Add => u128::overflowing_add,
Sub => u128::overflowing_sub, Sub => u128::overflowing_sub,
Mul => u128::overflowing_mul, Mul => u128::overflowing_mul,
Div if r == 0 => throw_panic!(DivisionByZero), Div if r == 0 => throw_ub!(DivisionByZero),
Rem if r == 0 => throw_panic!(RemainderByZero), Rem if r == 0 => throw_ub!(RemainderByZero),
Div => u128::overflowing_div, Div => u128::overflowing_div,
Rem => u128::overflowing_rem, Rem => u128::overflowing_rem,
_ => bug!(), _ => bug!(),

View File

@ -384,10 +384,8 @@ where
layout::FieldPlacement::Array { stride, .. } => { layout::FieldPlacement::Array { stride, .. } => {
let len = base.len(self)?; let len = base.len(self)?;
if field >= len { if field >= len {
// This can be violated because the index (field) can be a runtime value // This can only be reached in ConstProp and non-rustc-MIR.
// provided by the user. throw_ub!(BoundsCheckFailed { len, index: field });
debug!("tried to access element {} of array/slice with length {}", field, len);
throw_panic!(BoundsCheck { len, index: field });
} }
stride * field stride * field
} }

View File

@ -14,7 +14,6 @@ fn main() {
//~^ ERROR const_err //~^ ERROR const_err
let _e = [5u8][1]; let _e = [5u8][1];
//~^ ERROR const_err //~^ ERROR const_err
//~| ERROR this expression will panic at runtime
black_box(b); black_box(b);
black_box(c); black_box(c);
black_box(d); black_box(d);

View File

@ -12,7 +12,7 @@ error: reaching this expression at runtime will panic or abort
LL | &{[1, 2, 3][4]}; LL | &{[1, 2, 3][4]};
| --^^^^^^^^^^^^- | --^^^^^^^^^^^^-
| | | |
| index out of bounds: the len is 3 but the index is 4 | indexing out of bounds: the len is 3 but the index is 4
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View File

@ -23,7 +23,6 @@ fn main() {
//~^ ERROR const_err //~^ ERROR const_err
let _e = [5u8][1]; let _e = [5u8][1];
//~^ ERROR index out of bounds //~^ ERROR index out of bounds
//~| ERROR this expression will panic at runtime
black_box(a); black_box(a);
black_box(b); black_box(b);
black_box(c); black_box(c);

View File

@ -34,11 +34,5 @@ error: index out of bounds: the len is 1 but the index is 1
LL | let _e = [5u8][1]; LL | let _e = [5u8][1];
| ^^^^^^^^ | ^^^^^^^^
error: this expression will panic at runtime error: aborting due to 5 previous errors
--> $DIR/const-err2.rs:24:14
|
LL | let _e = [5u8][1];
| ^^^^^^^^ index out of bounds: the len is 1 but the index is 1
error: aborting due to 6 previous errors

View File

@ -23,7 +23,6 @@ fn main() {
//~^ ERROR const_err //~^ ERROR const_err
let _e = [5u8][1]; let _e = [5u8][1];
//~^ ERROR const_err //~^ ERROR const_err
//~| ERROR this expression will panic at runtime
black_box(a); black_box(a);
black_box(b); black_box(b);
black_box(c); black_box(c);

View File

@ -34,11 +34,5 @@ error: index out of bounds: the len is 1 but the index is 1
LL | let _e = [5u8][1]; LL | let _e = [5u8][1];
| ^^^^^^^^ | ^^^^^^^^
error: this expression will panic at runtime error: aborting due to 5 previous errors
--> $DIR/const-err3.rs:24:14
|
LL | let _e = [5u8][1];
| ^^^^^^^^ index out of bounds: the len is 1 but the index is 1
error: aborting due to 6 previous errors

View File

@ -8,14 +8,12 @@ fn main() {
//~^ ERROR const_err //~^ ERROR const_err
println!("{}", 1/(1-1)); println!("{}", 1/(1-1));
//~^ ERROR attempt to divide by zero [const_err] //~^ ERROR attempt to divide by zero [const_err]
//~| ERROR reaching this expression at runtime will panic or abort [const_err] //~| ERROR const_err
let _x = 1/(1-1); let _x = 1/(1-1);
//~^ ERROR const_err //~^ ERROR const_err
//~| ERROR const_err
println!("{}", 1/(false as u32)); println!("{}", 1/(false as u32));
//~^ ERROR attempt to divide by zero [const_err] //~^ ERROR attempt to divide by zero [const_err]
//~| ERROR reaching this expression at runtime will panic or abort [const_err] //~| ERROR const_err
let _x = 1/(false as u32); let _x = 1/(false as u32);
//~^ ERROR const_err //~^ ERROR const_err
//~| ERROR const_err
} }

View File

@ -20,7 +20,7 @@ error: reaching this expression at runtime will panic or abort
--> $DIR/promoted_errors.rs:9:20 --> $DIR/promoted_errors.rs:9:20
| |
LL | println!("{}", 1/(1-1)); LL | println!("{}", 1/(1-1));
| ^^^^^^^ attempt to divide by zero | ^^^^^^^ dividing by zero
error: attempt to divide by zero error: attempt to divide by zero
--> $DIR/promoted_errors.rs:12:14 --> $DIR/promoted_errors.rs:12:14
@ -28,35 +28,23 @@ error: attempt to divide by zero
LL | let _x = 1/(1-1); LL | let _x = 1/(1-1);
| ^^^^^^^ | ^^^^^^^
error: this expression will panic at runtime
--> $DIR/promoted_errors.rs:12:14
|
LL | let _x = 1/(1-1);
| ^^^^^^^ attempt to divide by zero
error: 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)); LL | println!("{}", 1/(false as u32));
| ^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^
error: reaching this expression at runtime will panic or abort 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)); LL | println!("{}", 1/(false as u32));
| ^^^^^^^^^^^^^^^^ attempt to divide by zero | ^^^^^^^^^^^^^^^^ dividing by zero
error: 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); LL | let _x = 1/(false as u32);
| ^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^
error: this expression will panic at runtime error: aborting due to 7 previous errors
--> $DIR/promoted_errors.rs:18:14
|
LL | let _x = 1/(false as u32);
| ^^^^^^^^^^^^^^^^ attempt to divide by zero
error: aborting due to 9 previous errors

View File

@ -9,14 +9,12 @@ fn main() {
//~^ ERROR attempt to subtract with overflow //~^ ERROR attempt to subtract with overflow
println!("{}", 1/(1-1)); println!("{}", 1/(1-1));
//~^ ERROR attempt to divide by zero [const_err] //~^ ERROR attempt to divide by zero [const_err]
//~| ERROR reaching this expression at runtime will panic or abort [const_err] //~| ERROR const_err
let _x = 1/(1-1); let _x = 1/(1-1);
//~^ ERROR const_err //~^ ERROR const_err
//~| ERROR const_err
println!("{}", 1/(false as u32)); println!("{}", 1/(false as u32));
//~^ ERROR attempt to divide by zero [const_err] //~^ ERROR attempt to divide by zero [const_err]
//~| ERROR reaching this expression at runtime will panic or abort [const_err] //~| ERROR const_err
let _x = 1/(false as u32); let _x = 1/(false as u32);
//~^ ERROR const_err //~^ ERROR const_err
//~| ERROR const_err
} }

View File

@ -26,7 +26,7 @@ error: reaching this expression at runtime will panic or abort
--> $DIR/promoted_errors2.rs:10:20 --> $DIR/promoted_errors2.rs:10:20
| |
LL | println!("{}", 1/(1-1)); LL | println!("{}", 1/(1-1));
| ^^^^^^^ attempt to divide by zero | ^^^^^^^ dividing by zero
error: attempt to divide by zero error: attempt to divide by zero
--> $DIR/promoted_errors2.rs:13:14 --> $DIR/promoted_errors2.rs:13:14
@ -34,35 +34,23 @@ error: attempt to divide by zero
LL | let _x = 1/(1-1); 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 error: attempt to divide by zero
--> $DIR/promoted_errors2.rs:16:20 --> $DIR/promoted_errors2.rs:15:20
| |
LL | println!("{}", 1/(false as u32)); LL | println!("{}", 1/(false as u32));
| ^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^
error: reaching this expression at runtime will panic or abort error: reaching this expression at runtime will panic or abort
--> $DIR/promoted_errors2.rs:16:20 --> $DIR/promoted_errors2.rs:15:20
| |
LL | println!("{}", 1/(false as u32)); LL | println!("{}", 1/(false as u32));
| ^^^^^^^^^^^^^^^^ attempt to divide by zero | ^^^^^^^^^^^^^^^^ dividing by zero
error: attempt to divide by zero error: attempt to divide by zero
--> $DIR/promoted_errors2.rs:19:14 --> $DIR/promoted_errors2.rs:18:14
| |
LL | let _x = 1/(false as u32); LL | let _x = 1/(false as u32);
| ^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^
error: this expression will panic at runtime error: aborting due to 8 previous errors
--> $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

View File

@ -1,4 +1,3 @@
fn main() { fn main() {
[0; 3][3u64 as usize]; //~ ERROR the len is 3 but the index is 3 [0; 3][3u64 as usize]; //~ ERROR the len is 3 but the index is 3
//~| ERROR this expression will panic at runtime
} }

View File

@ -6,11 +6,5 @@ LL | [0; 3][3u64 as usize];
| |
= note: `#[deny(const_err)]` on by default = note: `#[deny(const_err)]` on by default
error: this expression will panic at runtime error: aborting due to previous error
--> $DIR/const-prop-ice.rs:2:5
|
LL | [0; 3][3u64 as usize];
| ^^^^^^^^^^^^^^^^^^^^^ index out of bounds: the len is 3 but the index is 3
error: aborting due to 2 previous errors

View File

@ -1,7 +1,5 @@
fn main() { fn main() {
[1][0u64 as usize]; [1][0u64 as usize];
[1][1.5 as usize]; //~ ERROR index out of bounds [1][1.5 as usize]; //~ ERROR index out of bounds
//~| ERROR this expression will panic at runtime
[1][1u64 as usize]; //~ ERROR index out of bounds [1][1u64 as usize]; //~ ERROR index out of bounds
//~| ERROR this expression will panic at runtime
} }

View File

@ -6,23 +6,11 @@ LL | [1][1.5 as usize];
| |
= note: `#[deny(const_err)]` on by default = note: `#[deny(const_err)]` on by default
error: this expression will panic at runtime
--> $DIR/issue-54348.rs:3:5
|
LL | [1][1.5 as usize];
| ^^^^^^^^^^^^^^^^^ index out of bounds: the len is 1 but the index is 1
error: index out of bounds: the len is 1 but the index is 1 error: index out of bounds: the len is 1 but the index is 1
--> $DIR/issue-54348.rs:5:5 --> $DIR/issue-54348.rs:4:5
| |
LL | [1][1u64 as usize]; LL | [1][1u64 as usize];
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^
error: this expression will panic at runtime error: aborting due to 2 previous errors
--> $DIR/issue-54348.rs:5:5
|
LL | [1][1u64 as usize];
| ^^^^^^^^^^^^^^^^^^ index out of bounds: the len is 1 but the index is 1
error: aborting due to 4 previous errors

View File

@ -23,19 +23,14 @@ fn main() {
//~| ERROR this expression will panic at runtime //~| ERROR this expression will panic at runtime
assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err());
//~^ ERROR attempt to divide by zero //~^ ERROR attempt to divide by zero
//~| ERROR this expression will panic at runtime
assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err()); assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err());
//~^ ERROR attempt to divide by zero //~^ ERROR attempt to divide by zero
//~| ERROR this expression will panic at runtime
assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err()); assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err());
//~^ ERROR attempt to divide by zero //~^ ERROR attempt to divide by zero
//~| ERROR this expression will panic at runtime
assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err()); assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err());
//~^ ERROR attempt to divide by zero //~^ ERROR attempt to divide by zero
//~| ERROR this expression will panic at runtime
assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err()); assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err());
//~^ ERROR attempt to divide by zero //~^ ERROR attempt to divide by zero
//~| ERROR this expression will panic at runtime
assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err()); assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with overflow //~^ ERROR attempt to calculate the remainder with overflow
//~| ERROR this expression will panic at runtime //~| ERROR this expression will panic at runtime
@ -53,17 +48,12 @@ fn main() {
//~| ERROR this expression will panic at runtime //~| ERROR this expression will panic at runtime
assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err()); assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with a divisor of zero //~^ 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()); assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with a divisor of zero //~^ 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()); assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with a divisor of zero //~^ 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()); assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with a divisor of zero //~^ 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()); assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with a divisor of zero //~^ ERROR attempt to calculate the remainder with a divisor of zero
//~| ERROR this expression will panic at runtime
} }

View File

@ -70,179 +70,119 @@ error: attempt to divide by zero
LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err());
| ^^^^^^^^^^ | ^^^^^^^^^^
error: this expression will panic at runtime
--> $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 error: attempt to divide by zero
--> $DIR/issue-8460-const.rs:27:36 --> $DIR/issue-8460-const.rs:26:36
| |
LL | assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err()); LL | assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err());
| ^^^^^^^ | ^^^^^^^
error: this expression will panic at runtime
--> $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 error: attempt to divide by zero
--> $DIR/issue-8460-const.rs:30:36 --> $DIR/issue-8460-const.rs:28:36
| |
LL | assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err()); LL | assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err());
| ^^^^^^^^ | ^^^^^^^^
error: this expression will panic at runtime error: attempt to divide by zero
--> $DIR/issue-8460-const.rs:30: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:33:36
|
LL | assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err()); LL | assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err());
| ^^^^^^^^ | ^^^^^^^^
error: this expression will panic at runtime
--> $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 error: attempt to divide by zero
--> $DIR/issue-8460-const.rs:36:36 --> $DIR/issue-8460-const.rs:32:36
| |
LL | assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err()); LL | assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err());
| ^^^^^^^^ | ^^^^^^^^
error: this expression will panic at runtime
--> $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 error: attempt to calculate the remainder with overflow
--> $DIR/issue-8460-const.rs:39:36 --> $DIR/issue-8460-const.rs:34:36
| |
LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err()); LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^
error: this expression will panic at runtime error: this expression will panic at runtime
--> $DIR/issue-8460-const.rs:39:36 --> $DIR/issue-8460-const.rs:34:36
| |
LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err()); LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^^^^ attempt to calculate the remainder with overflow | ^^^^^^^^^^^^^^^ attempt to calculate the remainder with overflow
error: 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:37:36
| |
LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err()); LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
error: this expression will panic at runtime error: this expression will panic at runtime
--> $DIR/issue-8460-const.rs:42:36 --> $DIR/issue-8460-const.rs:37:36
| |
LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err()); LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^ attempt to calculate the remainder with overflow | ^^^^^^^^^^^^ attempt to calculate the remainder with overflow
error: attempt to calculate the remainder with overflow error: attempt to calculate the remainder with overflow
--> $DIR/issue-8460-const.rs:45:36 --> $DIR/issue-8460-const.rs:40:36
| |
LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err()); LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
error: this expression will panic at runtime error: this expression will panic at runtime
--> $DIR/issue-8460-const.rs:45:36 --> $DIR/issue-8460-const.rs:40:36
| |
LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err()); LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^^ attempt to calculate the remainder with overflow | ^^^^^^^^^^^^^ attempt to calculate the remainder with overflow
error: attempt to calculate the remainder with overflow error: attempt to calculate the remainder with overflow
--> $DIR/issue-8460-const.rs:48:36 --> $DIR/issue-8460-const.rs:43:36
| |
LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err()); LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
error: this expression will panic at runtime error: this expression will panic at runtime
--> $DIR/issue-8460-const.rs:48:36 --> $DIR/issue-8460-const.rs:43:36
| |
LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err()); LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^^ attempt to calculate the remainder with overflow | ^^^^^^^^^^^^^ attempt to calculate the remainder with overflow
error: attempt to calculate the remainder with overflow error: attempt to calculate the remainder with overflow
--> $DIR/issue-8460-const.rs:51:36 --> $DIR/issue-8460-const.rs:46:36
| |
LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err()); LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
error: this expression will panic at runtime error: this expression will panic at runtime
--> $DIR/issue-8460-const.rs:51:36 --> $DIR/issue-8460-const.rs:46:36
| |
LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err()); LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^^ attempt to calculate the remainder with overflow | ^^^^^^^^^^^^^ attempt to calculate the remainder with overflow
error: 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:49:36
| |
LL | assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err()); LL | assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err());
| ^^^^^^^^^^ | ^^^^^^^^^^
error: this expression will panic at runtime
--> $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 error: attempt to calculate the remainder with a divisor of zero
--> $DIR/issue-8460-const.rs:57:36 --> $DIR/issue-8460-const.rs:51:36
| |
LL | assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err()); LL | assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err());
| ^^^^^^^ | ^^^^^^^
error: this expression will panic at runtime error: attempt to calculate the remainder with a divisor of zero
--> $DIR/issue-8460-const.rs:53:36
|
LL | assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err());
| ^^^^^^^^
error: attempt to calculate the remainder with a divisor of zero
--> $DIR/issue-8460-const.rs:55:36
|
LL | assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err());
| ^^^^^^^^
error: attempt to calculate the remainder with a divisor of zero
--> $DIR/issue-8460-const.rs:57: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:60:36
|
LL | assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err());
| ^^^^^^^^
error: this expression will panic at runtime
--> $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:63:36
|
LL | assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err());
| ^^^^^^^^
error: this expression will panic at runtime
--> $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:66:36
|
LL | assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err()); LL | assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err());
| ^^^^^^^^ | ^^^^^^^^
error: this expression will panic at runtime error: aborting due to 30 previous errors
--> $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
error: aborting due to 40 previous errors

View File

@ -18,19 +18,14 @@ fn main() {
//~^ ERROR attempt to divide with overflow //~^ ERROR attempt to divide with overflow
assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err());
//~^ ERROR attempt to divide by zero //~^ ERROR attempt to divide by zero
//~| ERROR this expression will panic at runtime
assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err()); assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err());
//~^ ERROR attempt to divide by zero //~^ ERROR attempt to divide by zero
//~| ERROR this expression will panic at runtime
assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err()); assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err());
//~^ ERROR attempt to divide by zero //~^ ERROR attempt to divide by zero
//~| ERROR this expression will panic at runtime
assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err()); assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err());
//~^ ERROR attempt to divide by zero //~^ ERROR attempt to divide by zero
//~| ERROR this expression will panic at runtime
assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err()); assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err());
//~^ ERROR attempt to divide by zero //~^ ERROR attempt to divide by zero
//~| ERROR this expression will panic at runtime
assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err()); assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with overflow //~^ ERROR attempt to calculate the remainder with overflow
assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err()); assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err());
@ -43,17 +38,12 @@ fn main() {
//~^ ERROR attempt to calculate the remainder with overflow //~^ ERROR attempt to calculate the remainder with overflow
assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err()); assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with a divisor of zero //~^ 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()); assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with a divisor of zero //~^ 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()); assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with a divisor of zero //~^ 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()); assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with a divisor of zero //~^ 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()); assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with a divisor of zero //~^ ERROR attempt to calculate the remainder with a divisor of zero
//~| ERROR this expression will panic at runtime
} }

View File

@ -40,149 +40,89 @@ error: attempt to divide by zero
LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); 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 error: attempt to divide by zero
--> $DIR/issue-8460-const2.rs:22:36 --> $DIR/issue-8460-const2.rs:21:36
| |
LL | assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err()); 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 error: attempt to divide by zero
--> $DIR/issue-8460-const2.rs:25:36 --> $DIR/issue-8460-const2.rs:23:36
| |
LL | assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err()); LL | assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err());
| ^^^^^^^^ | ^^^^^^^^
error: this expression will panic at runtime error: attempt to divide by zero
--> $DIR/issue-8460-const2.rs:25:36 --> $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()); 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 error: attempt to divide by zero
--> $DIR/issue-8460-const2.rs:31:36 --> $DIR/issue-8460-const2.rs:27:36
| |
LL | assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err()); 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 error: attempt to calculate the remainder with overflow
--> $DIR/issue-8460-const2.rs:34:36 --> $DIR/issue-8460-const2.rs:29:36
| |
LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err()); LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^
error: attempt to calculate the remainder with overflow error: attempt to calculate the remainder with overflow
--> $DIR/issue-8460-const2.rs:36:36 --> $DIR/issue-8460-const2.rs:31:36
| |
LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err()); LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
error: attempt to calculate the remainder with overflow error: attempt to calculate the remainder with overflow
--> $DIR/issue-8460-const2.rs:38:36 --> $DIR/issue-8460-const2.rs:33:36
| |
LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err()); LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
error: attempt to calculate the remainder with overflow error: attempt to calculate the remainder with overflow
--> $DIR/issue-8460-const2.rs:40:36 --> $DIR/issue-8460-const2.rs:35:36
| |
LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err()); LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
error: attempt to calculate the remainder with overflow error: attempt to calculate the remainder with overflow
--> $DIR/issue-8460-const2.rs:42:36 --> $DIR/issue-8460-const2.rs:37:36
| |
LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err()); LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
error: 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:44:36 --> $DIR/issue-8460-const2.rs:39:36
| |
LL | assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err()); 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 error: attempt to calculate the remainder with a divisor of zero
--> $DIR/issue-8460-const2.rs:47:36 --> $DIR/issue-8460-const2.rs:41:36
| |
LL | assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err()); LL | assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err());
| ^^^^^^^ | ^^^^^^^
error: this expression will panic at runtime error: attempt to calculate the remainder with a divisor of zero
--> $DIR/issue-8460-const2.rs:43:36
|
LL | assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err());
| ^^^^^^^^
error: attempt to calculate the remainder with a divisor of zero
--> $DIR/issue-8460-const2.rs:45:36
|
LL | assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err());
| ^^^^^^^^
error: attempt to calculate the remainder with a divisor of zero
--> $DIR/issue-8460-const2.rs:47:36 --> $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()); LL | assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err());
| ^^^^^^^^ | ^^^^^^^^
error: this expression will panic at runtime error: aborting due to 20 previous errors
--> $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