]> git.proxmox.com Git - rustc.git/blob - src/test/ui/issues/issue-8460-const.rs
New upstream version 1.41.1+dfsg1
[rustc.git] / src / test / ui / issues / issue-8460-const.rs
1 // compile-flags: -O
2
3 #![deny(const_err)]
4
5 use std::{isize, i8, i16, i32, i64};
6 use std::thread;
7
8 fn main() {
9 assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err());
10 //~^ ERROR attempt to divide with overflow
11 //~| ERROR this expression will panic at runtime
12 assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err());
13 //~^ ERROR attempt to divide with overflow
14 //~| ERROR this expression will panic at runtime
15 assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err());
16 //~^ ERROR attempt to divide with overflow
17 //~| ERROR this expression will panic at runtime
18 assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err());
19 //~^ ERROR attempt to divide with overflow
20 //~| ERROR this expression will panic at runtime
21 assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err());
22 //~^ ERROR attempt to divide with overflow
23 //~| ERROR this expression will panic at runtime
24 assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err());
25 //~^ ERROR attempt to divide by zero
26 assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err());
27 //~^ ERROR attempt to divide by zero
28 assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err());
29 //~^ ERROR attempt to divide by zero
30 assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err());
31 //~^ ERROR attempt to divide by zero
32 assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err());
33 //~^ ERROR attempt to divide by zero
34 assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err());
35 //~^ ERROR attempt to calculate the remainder with overflow
36 //~| ERROR this expression will panic at runtime
37 assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err());
38 //~^ ERROR attempt to calculate the remainder with overflow
39 //~| ERROR this expression will panic at runtime
40 assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err());
41 //~^ ERROR attempt to calculate the remainder with overflow
42 //~| ERROR this expression will panic at runtime
43 assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err());
44 //~^ ERROR attempt to calculate the remainder with overflow
45 //~| ERROR this expression will panic at runtime
46 assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err());
47 //~^ ERROR attempt to calculate the remainder with overflow
48 //~| ERROR this expression will panic at runtime
49 assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err());
50 //~^ ERROR attempt to calculate the remainder with a divisor of zero
51 assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err());
52 //~^ ERROR attempt to calculate the remainder with a divisor of zero
53 assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err());
54 //~^ ERROR attempt to calculate the remainder with a divisor of zero
55 assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err());
56 //~^ ERROR attempt to calculate the remainder with a divisor of zero
57 assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err());
58 //~^ ERROR attempt to calculate the remainder with a divisor of zero
59 }