diff --git a/rust-version b/rust-version index cab2da408d..56281423c5 100644 --- a/rust-version +++ b/rust-version @@ -1 +1 @@ -f0c4da49983aa699f715caf681e3154b445fb60b +45660949132222ba7ec0905649b2affd68e0e13c diff --git a/tests/compile-fail/intrinsics/exact_div4.rs b/tests/compile-fail/intrinsics/exact_div4.rs index c241b2df66..2831795de8 100644 --- a/tests/compile-fail/intrinsics/exact_div4.rs +++ b/tests/compile-fail/intrinsics/exact_div4.rs @@ -1,5 +1,5 @@ #![feature(core_intrinsics)] fn main() { // divison of MIN by -1 - unsafe { std::intrinsics::exact_div(i64::MIN, -1); } //~ ERROR result of dividing MIN by -1 cannot be represented + unsafe { std::intrinsics::exact_div(i64::MIN, -1); } //~ ERROR overflow in signed remainder (dividing MIN by -1) } diff --git a/tests/compile-fail/intrinsics/simd-div-overflow.rs b/tests/compile-fail/intrinsics/simd-div-overflow.rs new file mode 100644 index 0000000000..277b9e807b --- /dev/null +++ b/tests/compile-fail/intrinsics/simd-div-overflow.rs @@ -0,0 +1,15 @@ +#![feature(platform_intrinsics, repr_simd)] + +extern "platform-intrinsic" { + pub(crate) fn simd_div(x: T, y: T) -> T; +} + +#[repr(simd)] +#[allow(non_camel_case_types)] +struct i32x2(i32, i32); + +fn main() { unsafe { + let x = i32x2(1, i32::MIN); + let y = i32x2(1, -1); + simd_div(x, y); //~ERROR Undefined Behavior: overflow in signed division +} } diff --git a/tests/compile-fail/intrinsics/unchecked_div1.rs b/tests/compile-fail/intrinsics/unchecked_div1.rs index 53d8000764..08b654da3e 100644 --- a/tests/compile-fail/intrinsics/unchecked_div1.rs +++ b/tests/compile-fail/intrinsics/unchecked_div1.rs @@ -1,5 +1,5 @@ #![feature(core_intrinsics)] fn main() { // MIN/-1 cannot be represented - unsafe { std::intrinsics::unchecked_div(i16::MIN, -1); } //~ ERROR overflow executing `unchecked_div` + unsafe { std::intrinsics::unchecked_div(i16::MIN, -1); } //~ ERROR overflow in signed division (dividing MIN by -1) } diff --git a/tests/run-pass/integer-ops.rs b/tests/run-pass/integer-ops.rs index 36bd579717..fde220d8f3 100644 --- a/tests/run-pass/integer-ops.rs +++ b/tests/run-pass/integer-ops.rs @@ -116,6 +116,9 @@ pub fn main() { assert_eq!(100i8.wrapping_rem(10), 0); assert_eq!((-128i8).wrapping_rem(-1), 0); + assert_eq!(i32::MIN.wrapping_div(-1), i32::MIN); + assert_eq!(i32::MIN.wrapping_rem(-1), 0); + assert_eq!(100i8.wrapping_neg(), -100); assert_eq!((-128i8).wrapping_neg(), -128);