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

68 lines
3.6 KiB
Rust
Raw Normal View History

#![deny(const_err)]
2015-02-27 01:43:55 +01:00
use std::{isize, i8, i16, i32, i64};
2015-02-17 15:10:25 -08:00
use std::thread;
fn main() {
2015-02-27 01:43:55 +01:00
assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err());
//~^ ERROR attempt to divide with overflow
2019-09-02 05:01:39 +09:00
//~| ERROR this expression will panic at runtime
2015-02-17 15:24:34 -08:00
assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err());
//~^ ERROR attempt to divide with overflow
2019-09-02 05:01:39 +09:00
//~| ERROR this expression will panic at runtime
2015-02-17 15:24:34 -08:00
assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err());
//~^ ERROR attempt to divide with overflow
2019-09-02 05:01:39 +09:00
//~| ERROR this expression will panic at runtime
2015-02-17 15:24:34 -08:00
assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err());
//~^ ERROR attempt to divide with overflow
2019-09-02 05:01:39 +09:00
//~| ERROR this expression will panic at runtime
2015-02-17 15:24:34 -08:00
assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err());
//~^ ERROR attempt to divide with overflow
2019-09-02 05:01:39 +09:00
//~| ERROR this expression will panic at runtime
assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err());
//~^ ERROR attempt to divide by zero
2018-06-02 23:38:57 +02:00
//~| ERROR this expression will panic at runtime
2015-02-17 15:24:34 -08:00
assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err());
//~^ ERROR attempt to divide by zero
2018-06-02 23:38:57 +02:00
//~| ERROR this expression will panic at runtime
2015-02-17 15:24:34 -08:00
assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err());
//~^ ERROR attempt to divide by zero
2018-06-02 23:38:57 +02:00
//~| ERROR this expression will panic at runtime
2015-02-17 15:24:34 -08:00
assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err());
//~^ ERROR attempt to divide by zero
2018-06-02 23:38:57 +02:00
//~| ERROR this expression will panic at runtime
2015-02-17 15:24:34 -08:00
assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err());
//~^ ERROR attempt to divide by zero
2018-06-02 23:38:57 +02:00
//~| ERROR this expression will panic at runtime
2015-02-27 01:43:55 +01:00
assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with overflow
2019-09-02 05:01:39 +09:00
//~| ERROR this expression will panic at runtime
2015-02-17 15:24:34 -08:00
assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with overflow
2019-09-02 05:01:39 +09:00
//~| ERROR this expression will panic at runtime
2015-02-17 15:24:34 -08:00
assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with overflow
2019-09-02 05:01:39 +09:00
//~| ERROR this expression will panic at runtime
2015-02-17 15:24:34 -08:00
assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with overflow
2019-09-02 05:01:39 +09:00
//~| ERROR this expression will panic at runtime
2015-02-17 15:24:34 -08:00
assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with overflow
2019-09-02 05:01:39 +09:00
//~| 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
2018-06-02 23:38:57 +02:00
//~| ERROR this expression will panic at runtime
2015-02-17 15:24:34 -08:00
assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with a divisor of zero
2018-06-02 23:38:57 +02:00
//~| ERROR this expression will panic at runtime
2015-02-17 15:24:34 -08:00
assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with a divisor of zero
2018-06-02 23:38:57 +02:00
//~| ERROR this expression will panic at runtime
2015-02-17 15:24:34 -08:00
assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with a divisor of zero
2018-06-02 23:38:57 +02:00
//~| ERROR this expression will panic at runtime
2015-02-17 15:24:34 -08:00
assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with a divisor of zero
2018-06-02 23:38:57 +02:00
//~| ERROR this expression will panic at runtime
}