Skip to content

Commit 1ddb050

Browse files
committed
div/rem overflow tests: also test i128
1 parent b434d7e commit 1ddb050

File tree

4 files changed

+117
-39
lines changed

4 files changed

+117
-39
lines changed

src/test/ui/issues/issue-8460-const.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#![deny(const_err)]
55

6-
use std::{isize, i8, i16, i32, i64};
6+
use std::{isize, i8, i16, i32, i64, i128};
77
use std::thread;
88

99
fn main() {
@@ -22,6 +22,9 @@ fn main() {
2222
assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err());
2323
//~^ ERROR attempt to divide with overflow
2424
//~| ERROR this expression will panic at runtime
25+
assert!(thread::spawn(move|| { i128::MIN / -1; }).join().is_err());
26+
//~^ ERROR attempt to divide with overflow
27+
//~| ERROR this expression will panic at runtime
2528
assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err());
2629
//~^ ERROR attempt to divide by zero
2730
assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err());
@@ -32,6 +35,8 @@ fn main() {
3235
//~^ ERROR attempt to divide by zero
3336
assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err());
3437
//~^ ERROR attempt to divide by zero
38+
assert!(thread::spawn(move|| { 1i128 / 0; }).join().is_err());
39+
//~^ ERROR attempt to divide by zero
3540
assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err());
3641
//~^ ERROR attempt to calculate the remainder with overflow
3742
//~| ERROR this expression will panic at runtime
@@ -47,6 +52,9 @@ fn main() {
4752
assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err());
4853
//~^ ERROR attempt to calculate the remainder with overflow
4954
//~| ERROR this expression will panic at runtime
55+
assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err());
56+
//~^ ERROR attempt to calculate the remainder with overflow
57+
//~| ERROR this expression will panic at runtime
5058
assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err());
5159
//~^ ERROR attempt to calculate the remainder with a divisor of zero
5260
assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err());
@@ -57,4 +65,6 @@ fn main() {
5765
//~^ ERROR attempt to calculate the remainder with a divisor of zero
5866
assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err());
5967
//~^ ERROR attempt to calculate the remainder with a divisor of zero
68+
assert!(thread::spawn(move|| { 1i128 % 0; }).join().is_err());
69+
//~^ ERROR attempt to calculate the remainder with a divisor of zero
6070
}

src/test/ui/issues/issue-8460-const.stderr

+57-21
Original file line numberDiff line numberDiff line change
@@ -64,125 +64,161 @@ error: this expression will panic at runtime
6464
LL | assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err());
6565
| ^^^^^^^^^^^^^ attempt to divide with overflow
6666

67-
error: attempt to divide by zero
67+
error: attempt to divide with overflow
68+
--> $DIR/issue-8460-const.rs:25:36
69+
|
70+
LL | assert!(thread::spawn(move|| { i128::MIN / -1; }).join().is_err());
71+
| ^^^^^^^^^^^^^^
72+
73+
error: this expression will panic at runtime
6874
--> $DIR/issue-8460-const.rs:25:36
6975
|
76+
LL | assert!(thread::spawn(move|| { i128::MIN / -1; }).join().is_err());
77+
| ^^^^^^^^^^^^^^ attempt to divide with overflow
78+
79+
error: attempt to divide by zero
80+
--> $DIR/issue-8460-const.rs:28:36
81+
|
7082
LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err());
7183
| ^^^^^^^^^^
7284

7385
error: attempt to divide by zero
74-
--> $DIR/issue-8460-const.rs:27:36
86+
--> $DIR/issue-8460-const.rs:30:36
7587
|
7688
LL | assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err());
7789
| ^^^^^^^
7890

7991
error: attempt to divide by zero
80-
--> $DIR/issue-8460-const.rs:29:36
92+
--> $DIR/issue-8460-const.rs:32:36
8193
|
8294
LL | assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err());
8395
| ^^^^^^^^
8496

8597
error: attempt to divide by zero
86-
--> $DIR/issue-8460-const.rs:31:36
98+
--> $DIR/issue-8460-const.rs:34:36
8799
|
88100
LL | assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err());
89101
| ^^^^^^^^
90102

91103
error: attempt to divide by zero
92-
--> $DIR/issue-8460-const.rs:33:36
104+
--> $DIR/issue-8460-const.rs:36:36
93105
|
94106
LL | assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err());
95107
| ^^^^^^^^
96108

109+
error: attempt to divide by zero
110+
--> $DIR/issue-8460-const.rs:38:36
111+
|
112+
LL | assert!(thread::spawn(move|| { 1i128 / 0; }).join().is_err());
113+
| ^^^^^^^^^
114+
97115
error: attempt to calculate the remainder with overflow
98-
--> $DIR/issue-8460-const.rs:35:36
116+
--> $DIR/issue-8460-const.rs:40:36
99117
|
100118
LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err());
101119
| ^^^^^^^^^^^^^^^
102120

103121
error: this expression will panic at runtime
104-
--> $DIR/issue-8460-const.rs:35:36
122+
--> $DIR/issue-8460-const.rs:40:36
105123
|
106124
LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err());
107125
| ^^^^^^^^^^^^^^^ attempt to calculate the remainder with overflow
108126

109127
error: attempt to calculate the remainder with overflow
110-
--> $DIR/issue-8460-const.rs:38:36
128+
--> $DIR/issue-8460-const.rs:43:36
111129
|
112130
LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err());
113131
| ^^^^^^^^^^^^
114132

115133
error: this expression will panic at runtime
116-
--> $DIR/issue-8460-const.rs:38:36
134+
--> $DIR/issue-8460-const.rs:43:36
117135
|
118136
LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err());
119137
| ^^^^^^^^^^^^ attempt to calculate the remainder with overflow
120138

121139
error: attempt to calculate the remainder with overflow
122-
--> $DIR/issue-8460-const.rs:41:36
140+
--> $DIR/issue-8460-const.rs:46:36
123141
|
124142
LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err());
125143
| ^^^^^^^^^^^^^
126144

127145
error: this expression will panic at runtime
128-
--> $DIR/issue-8460-const.rs:41:36
146+
--> $DIR/issue-8460-const.rs:46:36
129147
|
130148
LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err());
131149
| ^^^^^^^^^^^^^ attempt to calculate the remainder with overflow
132150

133151
error: attempt to calculate the remainder with overflow
134-
--> $DIR/issue-8460-const.rs:44:36
152+
--> $DIR/issue-8460-const.rs:49:36
135153
|
136154
LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err());
137155
| ^^^^^^^^^^^^^
138156

139157
error: this expression will panic at runtime
140-
--> $DIR/issue-8460-const.rs:44:36
158+
--> $DIR/issue-8460-const.rs:49:36
141159
|
142160
LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err());
143161
| ^^^^^^^^^^^^^ attempt to calculate the remainder with overflow
144162

145163
error: attempt to calculate the remainder with overflow
146-
--> $DIR/issue-8460-const.rs:47:36
164+
--> $DIR/issue-8460-const.rs:52:36
147165
|
148166
LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err());
149167
| ^^^^^^^^^^^^^
150168

151169
error: this expression will panic at runtime
152-
--> $DIR/issue-8460-const.rs:47:36
170+
--> $DIR/issue-8460-const.rs:52:36
153171
|
154172
LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err());
155173
| ^^^^^^^^^^^^^ attempt to calculate the remainder with overflow
156174

175+
error: attempt to calculate the remainder with overflow
176+
--> $DIR/issue-8460-const.rs:55:36
177+
|
178+
LL | assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err());
179+
| ^^^^^^^^^^^^^^
180+
181+
error: this expression will panic at runtime
182+
--> $DIR/issue-8460-const.rs:55:36
183+
|
184+
LL | assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err());
185+
| ^^^^^^^^^^^^^^ attempt to calculate the remainder with overflow
186+
157187
error: attempt to calculate the remainder with a divisor of zero
158-
--> $DIR/issue-8460-const.rs:50:36
188+
--> $DIR/issue-8460-const.rs:58:36
159189
|
160190
LL | assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err());
161191
| ^^^^^^^^^^
162192

163193
error: attempt to calculate the remainder with a divisor of zero
164-
--> $DIR/issue-8460-const.rs:52:36
194+
--> $DIR/issue-8460-const.rs:60:36
165195
|
166196
LL | assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err());
167197
| ^^^^^^^
168198

169199
error: attempt to calculate the remainder with a divisor of zero
170-
--> $DIR/issue-8460-const.rs:54:36
200+
--> $DIR/issue-8460-const.rs:62:36
171201
|
172202
LL | assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err());
173203
| ^^^^^^^^
174204

175205
error: attempt to calculate the remainder with a divisor of zero
176-
--> $DIR/issue-8460-const.rs:56:36
206+
--> $DIR/issue-8460-const.rs:64:36
177207
|
178208
LL | assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err());
179209
| ^^^^^^^^
180210

181211
error: attempt to calculate the remainder with a divisor of zero
182-
--> $DIR/issue-8460-const.rs:58:36
212+
--> $DIR/issue-8460-const.rs:66:36
183213
|
184214
LL | assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err());
185215
| ^^^^^^^^
186216

187-
error: aborting due to 30 previous errors
217+
error: attempt to calculate the remainder with a divisor of zero
218+
--> $DIR/issue-8460-const.rs:68:36
219+
|
220+
LL | assert!(thread::spawn(move|| { 1i128 % 0; }).join().is_err());
221+
| ^^^^^^^^^
222+
223+
error: aborting due to 36 previous errors
188224

src/test/ui/issues/issue-8460-const2.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#![deny(const_err)]
55

6-
use std::{isize, i8, i16, i32, i64};
6+
use std::{isize, i8, i16, i32, i64, i128};
77
use std::thread;
88

99
fn main() {
@@ -17,6 +17,8 @@ fn main() {
1717
//~^ ERROR attempt to divide with overflow
1818
assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err());
1919
//~^ ERROR attempt to divide with overflow
20+
assert!(thread::spawn(move|| { i128::MIN / -1; }).join().is_err());
21+
//~^ ERROR attempt to divide with overflow
2022
assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err());
2123
//~^ ERROR attempt to divide by zero
2224
assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err());
@@ -27,6 +29,8 @@ fn main() {
2729
//~^ ERROR attempt to divide by zero
2830
assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err());
2931
//~^ ERROR attempt to divide by zero
32+
assert!(thread::spawn(move|| { 1i128 / 0; }).join().is_err());
33+
//~^ ERROR attempt to divide by zero
3034
assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err());
3135
//~^ ERROR attempt to calculate the remainder with overflow
3236
assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err());
@@ -37,6 +41,8 @@ fn main() {
3741
//~^ ERROR attempt to calculate the remainder with overflow
3842
assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err());
3943
//~^ ERROR attempt to calculate the remainder with overflow
44+
assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err());
45+
//~^ ERROR attempt to calculate the remainder with overflow
4046
assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err());
4147
//~^ ERROR attempt to calculate the remainder with a divisor of zero
4248
assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err());
@@ -47,4 +53,6 @@ fn main() {
4753
//~^ ERROR attempt to calculate the remainder with a divisor of zero
4854
assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err());
4955
//~^ ERROR attempt to calculate the remainder with a divisor of zero
56+
assert!(thread::spawn(move|| { 1i128 % 0; }).join().is_err());
57+
//~^ ERROR attempt to calculate the remainder with a divisor of zero
5058
}

0 commit comments

Comments
 (0)