Merge pull request #525 from folkertdev/sync-from-rust-2026-04-28
Sync from rust 2026 04 28
diff --git a/crates/core_simd/src/masks.rs b/crates/core_simd/src/masks.rs
index a5334af..cb5d540 100644
--- a/crates/core_simd/src/masks.rs
+++ b/crates/core_simd/src/masks.rs
@@ -400,7 +400,15 @@
if min_index.eq(T::TRUE) {
None
} else {
- Some(min_index.to_usize())
+ let min_index = min_index.to_usize();
+
+ // Allow eliminating bounds checks when using the index
+ // Safety: the index can't exceed the number of elements in the vector
+ unsafe {
+ core::hint::assert_unchecked(min_index < N);
+ }
+
+ Some(min_index)
}
}
}
diff --git a/crates/core_simd/src/simd/num/float.rs b/crates/core_simd/src/simd/num/float.rs
index 510f4c9..14a31b5 100644
--- a/crates/core_simd/src/simd/num/float.rs
+++ b/crates/core_simd/src/simd/num/float.rs
@@ -430,14 +430,14 @@
#[inline]
fn reduce_max(self) -> Self::Scalar {
- // Safety: `self` is a float vector
- unsafe { core::intrinsics::simd::simd_reduce_max(self) }
+ // LLVM has no intrinsic we can use here
+ // (https://github.com/llvm/llvm-project/issues/185827).
+ self.as_array().iter().copied().fold(Self::Scalar::NAN, Self::Scalar::max)
}
#[inline]
fn reduce_min(self) -> Self::Scalar {
- // Safety: `self` is a float vector
- unsafe { core::intrinsics::simd::simd_reduce_min(self) }
+ self.as_array().iter().copied().fold(Self::Scalar::NAN, Self::Scalar::min)
}
}
)*
diff --git a/crates/core_simd/src/simd/prelude.rs b/crates/core_simd/src/simd/prelude.rs
index 6e93f16..51b8def 100644
--- a/crates/core_simd/src/simd/prelude.rs
+++ b/crates/core_simd/src/simd/prelude.rs
@@ -16,6 +16,10 @@
#[rustfmt::skip]
#[doc(no_inline)]
+pub use super::{f16x1, f16x2, f16x4, f16x8, f16x16, f16x32, f16x64};
+
+#[rustfmt::skip]
+#[doc(no_inline)]
pub use super::{f32x1, f32x2, f32x4, f32x8, f32x16, f32x32, f32x64};
#[rustfmt::skip]
diff --git a/crates/test_helpers/src/lib.rs b/crates/test_helpers/src/lib.rs
index 82adb06..ce3680a 100644
--- a/crates/test_helpers/src/lib.rs
+++ b/crates/test_helpers/src/lib.rs
@@ -122,12 +122,23 @@
proptest::test_runner::TestRunner::new(proptest::test_runner::Config::with_cases(4))
}
+#[track_caller]
+fn unwrap_test_error<T, U: std::fmt::Debug>(
+ x: Result<T, proptest::test_runner::TestError<U>>,
+) -> T {
+ // Using the `Display` instance of the error is much more readable.
+ match x {
+ Ok(v) => v,
+ Err(e) => panic!("{e}"),
+ }
+}
+
/// Test a function that takes a single value.
pub fn test_1<A: core::fmt::Debug + DefaultStrategy>(
f: &dyn Fn(A) -> proptest::test_runner::TestCaseResult,
) {
let mut runner = make_runner();
- runner.run(&A::default_strategy(), f).unwrap();
+ unwrap_test_error(runner.run(&A::default_strategy(), f))
}
/// Test a function that takes two values.
@@ -135,11 +146,11 @@
f: &dyn Fn(A, B) -> proptest::test_runner::TestCaseResult,
) {
let mut runner = make_runner();
- runner
- .run(&(A::default_strategy(), B::default_strategy()), |(a, b)| {
+ unwrap_test_error(
+ runner.run(&(A::default_strategy(), B::default_strategy()), |(a, b)| {
f(a, b)
- })
- .unwrap();
+ }),
+ )
}
/// Test a function that takes two values.
@@ -151,16 +162,14 @@
f: &dyn Fn(A, B, C) -> proptest::test_runner::TestCaseResult,
) {
let mut runner = make_runner();
- runner
- .run(
- &(
- A::default_strategy(),
- B::default_strategy(),
- C::default_strategy(),
- ),
- |(a, b, c)| f(a, b, c),
- )
- .unwrap();
+ unwrap_test_error(runner.run(
+ &(
+ A::default_strategy(),
+ B::default_strategy(),
+ C::default_strategy(),
+ ),
+ |(a, b, c)| f(a, b, c),
+ ));
}
/// Test a unary vector function against a unary scalar function, applied elementwise.