@@ -184,6 +184,9 @@ fn main() {
184
184
let _n = 1usize - 5 ; //~ ERROR: arithmetic operation will overflow
185
185
let _n = & ( 1usize - 5 ) ; //~ ERROR: arithmetic operation will overflow
186
186
187
+ let _n = -i8:: MIN ; //~ ERROR this arithmetic operation will overflow
188
+ let _n = & ( -i8:: MIN ) ; //~ ERROR this arithmetic operation will overflow
189
+
187
190
188
191
// Multiplication
189
192
let _n = u8:: MAX * 5 ; //~ ERROR: arithmetic operation will overflow
@@ -201,6 +204,9 @@ fn main() {
201
204
let _n = u128:: MAX * 5 ; //~ ERROR: arithmetic operation will overflow
202
205
let _n = & ( u128:: MAX * 5 ) ; //~ ERROR: arithmetic operation will overflow
203
206
207
+ let _n = usize:: MAX * 5 ; //~ ERROR: arithmetic operation will overflow
208
+ let _n = & ( usize:: MAX * 5 ) ; //~ ERROR: arithmetic operation will overflow
209
+
204
210
let _n = i8:: MAX * i8:: MAX ; //~ ERROR: arithmetic operation will overflow
205
211
let _n = & ( i8:: MAX * i8:: MAX ) ; //~ ERROR: arithmetic operation will overflow
206
212
@@ -219,12 +225,6 @@ fn main() {
219
225
let _n = isize:: MAX * 5 ; //~ ERROR: arithmetic operation will overflow
220
226
let _n = & ( isize:: MAX * 5 ) ; //~ ERROR: arithmetic operation will overflow
221
227
222
- let _n = usize:: MAX * 5 ; //~ ERROR: arithmetic operation will overflow
223
- let _n = & ( usize:: MAX * 5 ) ; //~ ERROR: arithmetic operation will overflow
224
-
225
- let _n = -i8:: MIN ; //~ ERROR this arithmetic operation will overflow
226
- let _n = & ( -i8:: MIN ) ; //~ ERROR this arithmetic operation will overflow
227
-
228
228
229
229
// Division
230
230
let _n = 1u8 / 0 ; //~ ERROR: this operation will panic at runtime
@@ -242,26 +242,44 @@ fn main() {
242
242
let _n = 1u128 / 0 ; //~ ERROR: this operation will panic at runtime
243
243
let _n = & ( 1u128 / 0 ) ; //~ ERROR: this operation will panic at runtime
244
244
245
+ let _n = 1usize / 0 ; //~ ERROR: this operation will panic at runtime
246
+ let _n = & ( 1usize / 0 ) ; //~ ERROR: this operation will panic at runtime
247
+
245
248
let _n = 1i8 / 0 ; //~ ERROR: this operation will panic at runtime
246
249
let _n = & ( 1i8 / 0 ) ; //~ ERROR: this operation will panic at runtime
250
+ let _n = i8:: MIN / -1 ; //~ ERROR: this operation will panic at runtime
251
+ let _n = & ( i8:: MIN / -1 ) ; //~ ERROR: this operation will panic at runtime
252
+ //~^ERROR: evaluation of constant value failed
247
253
248
254
let _n = 1i16 / 0 ; //~ ERROR: this operation will panic at runtime
249
255
let _n = & ( 1i16 / 0 ) ; //~ ERROR: this operation will panic at runtime
256
+ let _n = i16:: MIN / -1 ; //~ ERROR: this operation will panic at runtime
257
+ let _n = & ( i16:: MIN / -1 ) ; //~ ERROR: this operation will panic at runtime
258
+ //~^ERROR: evaluation of constant value failed
250
259
251
260
let _n = 1i32 / 0 ; //~ ERROR: this operation will panic at runtime
252
261
let _n = & ( 1i32 / 0 ) ; //~ ERROR: this operation will panic at runtime
262
+ let _n = i32:: MIN / -1 ; //~ ERROR: this operation will panic at runtime
263
+ let _n = & ( i32:: MIN / -1 ) ; //~ ERROR: this operation will panic at runtime
264
+ //~^ERROR: evaluation of constant value failed
253
265
254
266
let _n = 1i64 / 0 ; //~ ERROR: this operation will panic at runtime
255
267
let _n = & ( 1i64 / 0 ) ; //~ ERROR: this operation will panic at runtime
268
+ let _n = i64:: MIN / -1 ; //~ ERROR: this operation will panic at runtime
269
+ let _n = & ( i64:: MIN / -1 ) ; //~ ERROR: this operation will panic at runtime
270
+ //~^ERROR: evaluation of constant value failed
256
271
257
272
let _n = 1i128 / 0 ; //~ ERROR: this operation will panic at runtime
258
273
let _n = & ( 1i128 / 0 ) ; //~ ERROR: this operation will panic at runtime
274
+ let _n = i128:: MIN / -1 ; //~ ERROR: this operation will panic at runtime
275
+ let _n = & ( i128:: MIN / -1 ) ; //~ ERROR: this operation will panic at runtime
276
+ //~^ERROR: evaluation of constant value failed
259
277
260
278
let _n = 1isize / 0 ; //~ ERROR: this operation will panic at runtime
261
279
let _n = & ( 1isize / 0 ) ; //~ ERROR: this operation will panic at runtime
262
-
263
- let _n = 1usize / 0 ; //~ ERROR: this operation will panic at runtime
264
- let _n = & ( 1usize / 0 ) ; //~ ERROR: this operation will panic at runtime
280
+ let _n = isize :: MIN / - 1 ; //~ ERROR: this operation will panic at runtime
281
+ let _n = & ( isize :: MIN / - 1 ) ; //~ ERROR: this operation will panic at runtime
282
+ //~^ ERROR: evaluation of constant value failed
265
283
266
284
267
285
// Modulus
@@ -280,80 +298,46 @@ fn main() {
280
298
let _n = 1u128 % 0 ; //~ ERROR: this operation will panic at runtime
281
299
let _n = & ( 1u128 % 0 ) ; //~ ERROR: this operation will panic at runtime
282
300
301
+ let _n = 1usize % 0 ; //~ ERROR: this operation will panic at runtime
302
+ let _n = & ( 1usize % 0 ) ; //~ ERROR: this operation will panic at runtime
303
+
283
304
let _n = 1i8 % 0 ; //~ ERROR: this operation will panic at runtime
284
305
let _n = & ( 1i8 % 0 ) ; //~ ERROR: this operation will panic at runtime
306
+ let _n = i8:: MIN % -1 ; //~ ERROR: this operation will panic at runtime
307
+ let _n = & ( i8:: MIN % -1 ) ; //~ ERROR: this operation will panic at runtime
308
+ //~^ERROR: evaluation of constant value failed
285
309
286
310
let _n = 1i16 % 0 ; //~ ERROR: this operation will panic at runtime
287
311
let _n = & ( 1i16 % 0 ) ; //~ ERROR: this operation will panic at runtime
312
+ let _n = i16:: MIN % -1 ; //~ ERROR: this operation will panic at runtime
313
+ let _n = & ( i16:: MIN % -1 ) ; //~ ERROR: this operation will panic at runtime
314
+ //~^ERROR: evaluation of constant value failed
288
315
289
316
let _n = 1i32 % 0 ; //~ ERROR: this operation will panic at runtime
290
317
let _n = & ( 1i32 % 0 ) ; //~ ERROR: this operation will panic at runtime
318
+ let _n = i32:: MIN % -1 ; //~ ERROR: this operation will panic at runtime
319
+ let _n = & ( i32:: MIN % -1 ) ; //~ ERROR: this operation will panic at runtime
320
+ //~^ERROR: evaluation of constant value failed
291
321
292
322
let _n = 1i64 % 0 ; //~ ERROR: this operation will panic at runtime
293
323
let _n = & ( 1i64 % 0 ) ; //~ ERROR: this operation will panic at runtime
324
+ let _n = i64:: MIN % -1 ; //~ ERROR: this operation will panic at runtime
325
+ let _n = & ( i64:: MIN % -1 ) ; //~ ERROR: this operation will panic at runtime
326
+ //~^ERROR: evaluation of constant value failed
294
327
295
328
let _n = 1i128 % 0 ; //~ ERROR: this operation will panic at runtime
296
329
let _n = & ( 1i128 % 0 ) ; //~ ERROR: this operation will panic at runtime
330
+ let _n = i128:: MIN % -1 ; //~ ERROR: this operation will panic at runtime
331
+ let _n = & ( i128:: MIN % -1 ) ; //~ ERROR: this operation will panic at runtime
332
+ //~^ERROR: evaluation of constant value failed
297
333
298
334
let _n = 1isize % 0 ; //~ ERROR: this operation will panic at runtime
299
335
let _n = & ( 1isize % 0 ) ; //~ ERROR: this operation will panic at runtime
300
-
301
- let _n = 1usize % 0 ; //~ ERROR: this operation will panic at runtime
302
- let _n = & ( 1usize % 0 ) ; //~ ERROR: this operation will panic at runtime
303
-
336
+ let _n = isize:: MIN % -1 ; //~ ERROR: this operation will panic at runtime
337
+ let _n = & ( isize:: MIN % -1 ) ; //~ ERROR: this operation will panic at runtime
338
+ //~^ERROR: evaluation of constant value failed
304
339
305
340
// Out of bounds access
306
341
let _n = [ 1 , 2 , 3 ] [ 4 ] ; //~ ERROR: this operation will panic at runtime
307
342
let _n = & ( [ 1 , 2 , 3 ] [ 4 ] ) ; //~ ERROR: this operation will panic at runtime
308
-
309
-
310
- // issue-8460-const
311
- assert ! ( thread:: spawn( move|| { isize :: MIN / -1 ; } ) . join( ) . is_err( ) ) ;
312
- //~^ ERROR operation will panic
313
- assert ! ( thread:: spawn( move|| { i8 :: MIN / -1 ; } ) . join( ) . is_err( ) ) ;
314
- //~^ ERROR operation will panic
315
- assert ! ( thread:: spawn( move|| { i16 :: MIN / -1 ; } ) . join( ) . is_err( ) ) ;
316
- //~^ ERROR operation will panic
317
- assert ! ( thread:: spawn( move|| { i32 :: MIN / -1 ; } ) . join( ) . is_err( ) ) ;
318
- //~^ ERROR operation will panic
319
- assert ! ( thread:: spawn( move|| { i64 :: MIN / -1 ; } ) . join( ) . is_err( ) ) ;
320
- //~^ ERROR operation will panic
321
- assert ! ( thread:: spawn( move|| { i128 :: MIN / -1 ; } ) . join( ) . is_err( ) ) ;
322
- //~^ ERROR operation will panic
323
- assert ! ( thread:: spawn( move|| { 1isize / 0 ; } ) . join( ) . is_err( ) ) ;
324
- //~^ ERROR operation will panic
325
- assert ! ( thread:: spawn( move|| { 1i8 / 0 ; } ) . join( ) . is_err( ) ) ;
326
- //~^ ERROR operation will panic
327
- assert ! ( thread:: spawn( move|| { 1i16 / 0 ; } ) . join( ) . is_err( ) ) ;
328
- //~^ ERROR operation will panic
329
- assert ! ( thread:: spawn( move|| { 1i32 / 0 ; } ) . join( ) . is_err( ) ) ;
330
- //~^ ERROR operation will panic
331
- assert ! ( thread:: spawn( move|| { 1i64 / 0 ; } ) . join( ) . is_err( ) ) ;
332
- //~^ ERROR operation will panic
333
- assert ! ( thread:: spawn( move|| { 1i128 / 0 ; } ) . join( ) . is_err( ) ) ;
334
- //~^ ERROR operation will panic
335
- assert ! ( thread:: spawn( move|| { isize :: MIN % -1 ; } ) . join( ) . is_err( ) ) ;
336
- //~^ ERROR operation will panic
337
- assert ! ( thread:: spawn( move|| { i8 :: MIN % -1 ; } ) . join( ) . is_err( ) ) ;
338
- //~^ ERROR operation will panic
339
- assert ! ( thread:: spawn( move|| { i16 :: MIN % -1 ; } ) . join( ) . is_err( ) ) ;
340
- //~^ ERROR operation will panic
341
- assert ! ( thread:: spawn( move|| { i32 :: MIN % -1 ; } ) . join( ) . is_err( ) ) ;
342
- //~^ ERROR operation will panic
343
- assert ! ( thread:: spawn( move|| { i64 :: MIN % -1 ; } ) . join( ) . is_err( ) ) ;
344
- //~^ ERROR operation will panic
345
- assert ! ( thread:: spawn( move|| { i128 :: MIN % -1 ; } ) . join( ) . is_err( ) ) ;
346
- //~^ ERROR operation will panic
347
- assert ! ( thread:: spawn( move|| { 1isize % 0 ; } ) . join( ) . is_err( ) ) ;
348
- //~^ ERROR operation will panic
349
- assert ! ( thread:: spawn( move|| { 1i8 % 0 ; } ) . join( ) . is_err( ) ) ;
350
- //~^ ERROR operation will panic
351
- assert ! ( thread:: spawn( move|| { 1i16 % 0 ; } ) . join( ) . is_err( ) ) ;
352
- //~^ ERROR operation will panic
353
- assert ! ( thread:: spawn( move|| { 1i32 % 0 ; } ) . join( ) . is_err( ) ) ;
354
- //~^ ERROR operation will panic
355
- assert ! ( thread:: spawn( move|| { 1i64 % 0 ; } ) . join( ) . is_err( ) ) ;
356
- //~^ ERROR operation will panic
357
- assert ! ( thread:: spawn( move|| { 1i128 % 0 ; } ) . join( ) . is_err( ) ) ;
358
- //~^ ERROR operation will panic
359
343
}
0 commit comments