div/rem overflow tests: also test i128
This commit is contained in:
parent
b434d7ef8a
commit
1ddb0503ff
4 changed files with 117 additions and 39 deletions
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#![deny(const_err)]
|
||||
|
||||
use std::{isize, i8, i16, i32, i64};
|
||||
use std::{isize, i8, i16, i32, i64, i128};
|
||||
use std::thread;
|
||||
|
||||
fn main() {
|
||||
|
|
@ -22,6 +22,9 @@ fn main() {
|
|||
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|| { i128::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
|
||||
assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err());
|
||||
|
|
@ -32,6 +35,8 @@ fn main() {
|
|||
//~^ ERROR attempt to divide by zero
|
||||
assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err());
|
||||
//~^ ERROR attempt to divide by zero
|
||||
assert!(thread::spawn(move|| { 1i128 / 0; }).join().is_err());
|
||||
//~^ ERROR attempt to divide by zero
|
||||
assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err());
|
||||
//~^ ERROR attempt to calculate the remainder with overflow
|
||||
//~| ERROR this expression will panic at runtime
|
||||
|
|
@ -47,6 +52,9 @@ fn main() {
|
|||
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|| { i128::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
|
||||
assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err());
|
||||
|
|
@ -57,4 +65,6 @@ fn main() {
|
|||
//~^ ERROR attempt to calculate the remainder with a divisor of zero
|
||||
assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err());
|
||||
//~^ ERROR attempt to calculate the remainder with a divisor of zero
|
||||
assert!(thread::spawn(move|| { 1i128 % 0; }).join().is_err());
|
||||
//~^ ERROR attempt to calculate the remainder with a divisor of zero
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,125 +64,161 @@ error: this expression will panic at runtime
|
|||
LL | assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err());
|
||||
| ^^^^^^^^^^^^^ attempt to divide with overflow
|
||||
|
||||
error: attempt to divide by zero
|
||||
error: attempt to divide with overflow
|
||||
--> $DIR/issue-8460-const.rs:25:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { i128::MIN / -1; }).join().is_err());
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression will panic at runtime
|
||||
--> $DIR/issue-8460-const.rs:25:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { i128::MIN / -1; }).join().is_err());
|
||||
| ^^^^^^^^^^^^^^ attempt to divide with overflow
|
||||
|
||||
error: attempt to divide by zero
|
||||
--> $DIR/issue-8460-const.rs:28:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err());
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: attempt to divide by zero
|
||||
--> $DIR/issue-8460-const.rs:27:36
|
||||
--> $DIR/issue-8460-const.rs:30:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err());
|
||||
| ^^^^^^^
|
||||
|
||||
error: attempt to divide by zero
|
||||
--> $DIR/issue-8460-const.rs:29:36
|
||||
--> $DIR/issue-8460-const.rs:32:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err());
|
||||
| ^^^^^^^^
|
||||
|
||||
error: attempt to divide by zero
|
||||
--> $DIR/issue-8460-const.rs:31:36
|
||||
--> $DIR/issue-8460-const.rs:34:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err());
|
||||
| ^^^^^^^^
|
||||
|
||||
error: attempt to divide by zero
|
||||
--> $DIR/issue-8460-const.rs:33:36
|
||||
--> $DIR/issue-8460-const.rs:36:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err());
|
||||
| ^^^^^^^^
|
||||
|
||||
error: attempt to divide by zero
|
||||
--> $DIR/issue-8460-const.rs:38:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1i128 / 0; }).join().is_err());
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: attempt to calculate the remainder with overflow
|
||||
--> $DIR/issue-8460-const.rs:35:36
|
||||
--> $DIR/issue-8460-const.rs:40:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err());
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression will panic at runtime
|
||||
--> $DIR/issue-8460-const.rs:35:36
|
||||
--> $DIR/issue-8460-const.rs:40:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err());
|
||||
| ^^^^^^^^^^^^^^^ attempt to calculate the remainder with overflow
|
||||
|
||||
error: attempt to calculate the remainder with overflow
|
||||
--> $DIR/issue-8460-const.rs:38:36
|
||||
--> $DIR/issue-8460-const.rs:43:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err());
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error: this expression will panic at runtime
|
||||
--> $DIR/issue-8460-const.rs:38:36
|
||||
--> $DIR/issue-8460-const.rs:43:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err());
|
||||
| ^^^^^^^^^^^^ attempt to calculate the remainder with overflow
|
||||
|
||||
error: attempt to calculate the remainder with overflow
|
||||
--> $DIR/issue-8460-const.rs:41:36
|
||||
--> $DIR/issue-8460-const.rs:46:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err());
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: this expression will panic at runtime
|
||||
--> $DIR/issue-8460-const.rs:41:36
|
||||
--> $DIR/issue-8460-const.rs:46:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err());
|
||||
| ^^^^^^^^^^^^^ attempt to calculate the remainder with overflow
|
||||
|
||||
error: attempt to calculate the remainder with overflow
|
||||
--> $DIR/issue-8460-const.rs:44:36
|
||||
--> $DIR/issue-8460-const.rs:49:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err());
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: this expression will panic at runtime
|
||||
--> $DIR/issue-8460-const.rs:44:36
|
||||
--> $DIR/issue-8460-const.rs:49:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err());
|
||||
| ^^^^^^^^^^^^^ attempt to calculate the remainder with overflow
|
||||
|
||||
error: attempt to calculate the remainder with overflow
|
||||
--> $DIR/issue-8460-const.rs:47:36
|
||||
--> $DIR/issue-8460-const.rs:52:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err());
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: this expression will panic at runtime
|
||||
--> $DIR/issue-8460-const.rs:47:36
|
||||
--> $DIR/issue-8460-const.rs:52:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err());
|
||||
| ^^^^^^^^^^^^^ attempt to calculate the remainder with overflow
|
||||
|
||||
error: attempt to calculate the remainder with overflow
|
||||
--> $DIR/issue-8460-const.rs:55:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err());
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression will panic at runtime
|
||||
--> $DIR/issue-8460-const.rs:55:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err());
|
||||
| ^^^^^^^^^^^^^^ attempt to calculate the remainder with overflow
|
||||
|
||||
error: attempt to calculate the remainder with a divisor of zero
|
||||
--> $DIR/issue-8460-const.rs:50:36
|
||||
--> $DIR/issue-8460-const.rs:58:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err());
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: attempt to calculate the remainder with a divisor of zero
|
||||
--> $DIR/issue-8460-const.rs:52:36
|
||||
--> $DIR/issue-8460-const.rs:60:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err());
|
||||
| ^^^^^^^
|
||||
|
||||
error: attempt to calculate the remainder with a divisor of zero
|
||||
--> $DIR/issue-8460-const.rs:54:36
|
||||
--> $DIR/issue-8460-const.rs:62:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err());
|
||||
| ^^^^^^^^
|
||||
|
||||
error: attempt to calculate the remainder with a divisor of zero
|
||||
--> $DIR/issue-8460-const.rs:56:36
|
||||
--> $DIR/issue-8460-const.rs:64:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err());
|
||||
| ^^^^^^^^
|
||||
|
||||
error: attempt to calculate the remainder with a divisor of zero
|
||||
--> $DIR/issue-8460-const.rs:58:36
|
||||
--> $DIR/issue-8460-const.rs:66:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err());
|
||||
| ^^^^^^^^
|
||||
|
||||
error: aborting due to 30 previous errors
|
||||
error: attempt to calculate the remainder with a divisor of zero
|
||||
--> $DIR/issue-8460-const.rs:68:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1i128 % 0; }).join().is_err());
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: aborting due to 36 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#![deny(const_err)]
|
||||
|
||||
use std::{isize, i8, i16, i32, i64};
|
||||
use std::{isize, i8, i16, i32, i64, i128};
|
||||
use std::thread;
|
||||
|
||||
fn main() {
|
||||
|
|
@ -17,6 +17,8 @@ fn main() {
|
|||
//~^ ERROR attempt to divide with overflow
|
||||
assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err());
|
||||
//~^ ERROR attempt to divide with overflow
|
||||
assert!(thread::spawn(move|| { i128::MIN / -1; }).join().is_err());
|
||||
//~^ ERROR attempt to divide with overflow
|
||||
assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err());
|
||||
//~^ ERROR attempt to divide by zero
|
||||
assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err());
|
||||
|
|
@ -27,6 +29,8 @@ fn main() {
|
|||
//~^ ERROR attempt to divide by zero
|
||||
assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err());
|
||||
//~^ ERROR attempt to divide by zero
|
||||
assert!(thread::spawn(move|| { 1i128 / 0; }).join().is_err());
|
||||
//~^ ERROR attempt to divide by zero
|
||||
assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err());
|
||||
//~^ ERROR attempt to calculate the remainder with overflow
|
||||
assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err());
|
||||
|
|
@ -37,6 +41,8 @@ fn main() {
|
|||
//~^ ERROR attempt to calculate the remainder with overflow
|
||||
assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err());
|
||||
//~^ ERROR attempt to calculate the remainder with overflow
|
||||
assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err());
|
||||
//~^ ERROR attempt to calculate the remainder with overflow
|
||||
assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err());
|
||||
//~^ ERROR attempt to calculate the remainder with a divisor of zero
|
||||
assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err());
|
||||
|
|
@ -47,4 +53,6 @@ fn main() {
|
|||
//~^ ERROR attempt to calculate the remainder with a divisor of zero
|
||||
assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err());
|
||||
//~^ ERROR attempt to calculate the remainder with a divisor of zero
|
||||
assert!(thread::spawn(move|| { 1i128 % 0; }).join().is_err());
|
||||
//~^ ERROR attempt to calculate the remainder with a divisor of zero
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,95 +34,119 @@ error: attempt to divide with overflow
|
|||
LL | assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err());
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: attempt to divide by zero
|
||||
error: attempt to divide with overflow
|
||||
--> $DIR/issue-8460-const2.rs:20:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { i128::MIN / -1; }).join().is_err());
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: attempt to divide by zero
|
||||
--> $DIR/issue-8460-const2.rs:22:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err());
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: attempt to divide by zero
|
||||
--> $DIR/issue-8460-const2.rs:22:36
|
||||
--> $DIR/issue-8460-const2.rs:24:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err());
|
||||
| ^^^^^^^
|
||||
|
||||
error: attempt to divide by zero
|
||||
--> $DIR/issue-8460-const2.rs:24:36
|
||||
--> $DIR/issue-8460-const2.rs:26:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err());
|
||||
| ^^^^^^^^
|
||||
|
||||
error: attempt to divide by zero
|
||||
--> $DIR/issue-8460-const2.rs:26:36
|
||||
--> $DIR/issue-8460-const2.rs:28:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err());
|
||||
| ^^^^^^^^
|
||||
|
||||
error: attempt to divide by zero
|
||||
--> $DIR/issue-8460-const2.rs:28:36
|
||||
--> $DIR/issue-8460-const2.rs:30:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err());
|
||||
| ^^^^^^^^
|
||||
|
||||
error: attempt to divide by zero
|
||||
--> $DIR/issue-8460-const2.rs:32:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1i128 / 0; }).join().is_err());
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: attempt to calculate the remainder with overflow
|
||||
--> $DIR/issue-8460-const2.rs:30:36
|
||||
--> $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:32:36
|
||||
--> $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:34:36
|
||||
--> $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:36:36
|
||||
--> $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:38:36
|
||||
--> $DIR/issue-8460-const2.rs:42:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err());
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: attempt to calculate the remainder with overflow
|
||||
--> $DIR/issue-8460-const2.rs:44:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err());
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: attempt to calculate the remainder with a divisor of zero
|
||||
--> $DIR/issue-8460-const2.rs:40:36
|
||||
--> $DIR/issue-8460-const2.rs:46:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err());
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: attempt to calculate the remainder with a divisor of zero
|
||||
--> $DIR/issue-8460-const2.rs:42:36
|
||||
--> $DIR/issue-8460-const2.rs:48:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err());
|
||||
| ^^^^^^^
|
||||
|
||||
error: attempt to calculate the remainder with a divisor of zero
|
||||
--> $DIR/issue-8460-const2.rs:44:36
|
||||
--> $DIR/issue-8460-const2.rs:50:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err());
|
||||
| ^^^^^^^^
|
||||
|
||||
error: attempt to calculate the remainder with a divisor of zero
|
||||
--> $DIR/issue-8460-const2.rs:46:36
|
||||
--> $DIR/issue-8460-const2.rs:52:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err());
|
||||
| ^^^^^^^^
|
||||
|
||||
error: attempt to calculate the remainder with a divisor of zero
|
||||
--> $DIR/issue-8460-const2.rs:48:36
|
||||
--> $DIR/issue-8460-const2.rs:54:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err());
|
||||
| ^^^^^^^^
|
||||
|
||||
error: aborting due to 20 previous errors
|
||||
error: attempt to calculate the remainder with a divisor of zero
|
||||
--> $DIR/issue-8460-const2.rs:56:36
|
||||
|
|
||||
LL | assert!(thread::spawn(move|| { 1i128 % 0; }).join().is_err());
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: aborting due to 24 previous errors
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue