]> git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/issue-8460-const.rs
Imported Upstream version 1.9.0+dfsg1
[rustc.git] / src / test / compile-fail / issue-8460-const.rs
1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 #![deny(const_err)]
12
13 use std::{isize, i8, i16, i32, i64};
14 use std::thread;
15
16 fn main() {
17 assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err());
18 //~^ ERROR attempted to divide with overflow
19 assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err());
20 //~^ ERROR attempted to divide with overflow
21 assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err());
22 //~^ ERROR attempted to divide with overflow
23 assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err());
24 //~^ ERROR attempted to divide with overflow
25 assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err());
26 //~^ ERROR attempted to divide with overflow
27 assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err());
28 //~^ ERROR attempted to divide by zero
29 assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err());
30 //~^ ERROR attempted to divide by zero
31 assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err());
32 //~^ ERROR attempted to divide by zero
33 assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err());
34 //~^ ERROR attempted to divide by zero
35 assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err());
36 //~^ ERROR attempted to divide by zero
37 assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err());
38 //~^ ERROR attempted to calculate the remainder with overflow
39 assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err());
40 //~^ ERROR attempted to calculate the remainder with overflow
41 assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err());
42 //~^ ERROR attempted to calculate the remainder with overflow
43 assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err());
44 //~^ ERROR attempted to calculate the remainder with overflow
45 assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err());
46 //~^ ERROR attempted to calculate the remainder with overflow
47 assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err());
48 //~^ ERROR attempted to calculate the remainder with a divisor of zero
49 assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err());
50 //~^ ERROR attempted to calculate the remainder with a divisor of zero
51 assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err());
52 //~^ ERROR attempted to calculate the remainder with a divisor of zero
53 assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err());
54 //~^ ERROR attempted to calculate the remainder with a divisor of zero
55 assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err());
56 //~^ ERROR attempted to calculate the remainder with a divisor of zero
57 }