2018-08-30 12:18:55 +00:00
|
|
|
// run-pass
|
2018-09-25 21:51:35 +00:00
|
|
|
#![allow(unused_must_use)]
|
2016-02-11 11:34:41 +00:00
|
|
|
// ignore-emscripten no threads support
|
2022-03-19 15:13:18 +00:00
|
|
|
// needs-unwind
|
2017-04-20 22:12:42 +00:00
|
|
|
#![feature(rustc_attrs)]
|
2015-03-22 20:13:15 +00:00
|
|
|
|
2015-02-17 23:24:34 +00:00
|
|
|
use std::thread;
|
2014-06-05 19:23:34 +00:00
|
|
|
|
2017-04-20 22:12:42 +00:00
|
|
|
trait Int {
|
|
|
|
fn zero() -> Self;
|
|
|
|
fn one() -> Self;
|
|
|
|
}
|
|
|
|
macro_rules! doit {
|
|
|
|
($($t:ident)*) => ($(impl Int for $t {
|
2020-01-06 04:33:31 +00:00
|
|
|
fn zero() -> Self { 0 }
|
|
|
|
fn one() -> Self { 1 }
|
2017-04-20 22:12:42 +00:00
|
|
|
})*)
|
|
|
|
}
|
|
|
|
doit! { i8 i16 i32 i64 isize }
|
|
|
|
|
2016-03-10 19:20:09 +00:00
|
|
|
macro_rules! check {
|
|
|
|
($($e:expr),*) => {
|
|
|
|
$(assert!(thread::spawn({
|
|
|
|
move|| { $e; }
|
|
|
|
}).join().is_err());)*
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-05 19:23:34 +00:00
|
|
|
fn main() {
|
2016-03-10 19:20:09 +00:00
|
|
|
check![
|
2020-06-02 07:59:11 +00:00
|
|
|
isize::MIN / -isize::one(),
|
|
|
|
i8::MIN / -i8::one(),
|
|
|
|
i16::MIN / -i16::one(),
|
|
|
|
i32::MIN / -i32::one(),
|
|
|
|
i64::MIN / -i64::one(),
|
2016-03-10 19:20:09 +00:00
|
|
|
1isize / isize::zero(),
|
|
|
|
1i8 / i8::zero(),
|
|
|
|
1i16 / i16::zero(),
|
|
|
|
1i32 / i32::zero(),
|
|
|
|
1i64 / i64::zero(),
|
2020-06-02 07:59:11 +00:00
|
|
|
isize::MIN % -isize::one(),
|
|
|
|
i8::MIN % -i8::one(),
|
|
|
|
i16::MIN % -i16::one(),
|
|
|
|
i32::MIN % -i32::one(),
|
|
|
|
i64::MIN % -i64::one(),
|
2016-03-10 19:20:09 +00:00
|
|
|
1isize % isize::zero(),
|
|
|
|
1i8 % i8::zero(),
|
|
|
|
1i16 % i16::zero(),
|
|
|
|
1i32 % i32::zero(),
|
|
|
|
1i64 % i64::zero()
|
|
|
|
];
|
2014-06-05 19:23:34 +00:00
|
|
|
}
|