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