rust/tests/ui/numbers-arithmetic/issue-8460.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

53 lines
1.1 KiB
Rust
Raw Normal View History

// run-pass
#![allow(unused_must_use)]
// ignore-emscripten no threads support
// needs-unwind
#![feature(rustc_attrs)]
2015-02-17 23:24:34 +00:00
use std::thread;
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 }
})*)
}
doit! { i8 i16 i32 i64 isize }
macro_rules! check {
($($e:expr),*) => {
$(assert!(thread::spawn({
move|| { $e; }
}).join().is_err());)*
}
}
fn main() {
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(),
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(),
1isize % isize::zero(),
1i8 % i8::zero(),
1i16 % i16::zero(),
1i32 % i32::zero(),
1i64 % i64::zero()
];
}