diff --git a/crates/core_simd/tests/float.rs b/crates/core_simd/tests/float.rs index 56d66239e806..03d132ae0468 100644 --- a/crates/core_simd/tests/float.rs +++ b/crates/core_simd/tests/float.rs @@ -6,9 +6,9 @@ macro_rules! impl_op_test { test_helpers::test_lanes! { fn $fn() { test_helpers::test_unary_elementwise( - <$vector as core::ops::$trait>::$fn, - <$scalar as core::ops::$trait>::$fn, - |_| true, + &<$vector as core::ops::$trait>::$fn, + &<$scalar as core::ops::$trait>::$fn, + &|_| true, ); } } @@ -20,41 +20,41 @@ macro_rules! impl_op_test { test_helpers::test_lanes! { fn normal() { test_helpers::test_binary_elementwise( - <$vector as core::ops::$trait>::$fn, - <$scalar as core::ops::$trait>::$fn, - |_, _| true, + &<$vector as core::ops::$trait>::$fn, + &<$scalar as core::ops::$trait>::$fn, + &|_, _| true, ); } fn scalar_rhs() { test_helpers::test_binary_scalar_rhs_elementwise( - <$vector as core::ops::$trait<$scalar>>::$fn, - <$scalar as core::ops::$trait>::$fn, - |_, _| true, + &<$vector as core::ops::$trait<$scalar>>::$fn, + &<$scalar as core::ops::$trait>::$fn, + &|_, _| true, ); } fn scalar_lhs() { test_helpers::test_binary_scalar_lhs_elementwise( - <$scalar as core::ops::$trait<$vector>>::$fn, - <$scalar as core::ops::$trait>::$fn, - |_, _| true, + &<$scalar as core::ops::$trait<$vector>>::$fn, + &<$scalar as core::ops::$trait>::$fn, + &|_, _| true, ); } fn assign() { test_helpers::test_binary_elementwise( - |mut a, b| { <$vector as core::ops::$trait_assign>::$fn_assign(&mut a, b); a }, - |mut a, b| { <$scalar as core::ops::$trait_assign>::$fn_assign(&mut a, b); a }, - |_, _| true, + &|mut a, b| { <$vector as core::ops::$trait_assign>::$fn_assign(&mut a, b); a }, + &|mut a, b| { <$scalar as core::ops::$trait_assign>::$fn_assign(&mut a, b); a }, + &|_, _| true, ) } fn assign_scalar_rhs() { test_helpers::test_binary_scalar_rhs_elementwise( - |mut a, b| { <$vector as core::ops::$trait_assign<$scalar>>::$fn_assign(&mut a, b); a }, - |mut a, b| { <$scalar as core::ops::$trait_assign>::$fn_assign(&mut a, b); a }, - |_, _| true, + &|mut a, b| { <$vector as core::ops::$trait_assign<$scalar>>::$fn_assign(&mut a, b); a }, + &|mut a, b| { <$scalar as core::ops::$trait_assign>::$fn_assign(&mut a, b); a }, + &|_, _| true, ) } } @@ -79,33 +79,33 @@ macro_rules! impl_tests { test_helpers::test_lanes! { fn abs() { test_helpers::test_unary_elementwise( - Vector::::abs, - Scalar::abs, - |_| true, + &Vector::::abs, + &Scalar::abs, + &|_| true, ) } fn ceil() { test_helpers::test_unary_elementwise( - Vector::::ceil, - Scalar::ceil, - |_| true, + &Vector::::ceil, + &Scalar::ceil, + &|_| true, ) } fn floor() { test_helpers::test_unary_elementwise( - Vector::::floor, - Scalar::floor, - |_| true, + &Vector::::floor, + &Scalar::floor, + &|_| true, ) } fn round_from_int() { test_helpers::test_unary_elementwise( - Vector::::round_from_int, - |x| x as Scalar, - |_| true, + &Vector::::round_from_int, + &|x| x as Scalar, + &|_| true, ) } diff --git a/crates/core_simd/tests/integer.rs b/crates/core_simd/tests/integer.rs index 4f38cdb1ed63..878b3f0329a4 100644 --- a/crates/core_simd/tests/integer.rs +++ b/crates/core_simd/tests/integer.rs @@ -6,9 +6,9 @@ macro_rules! impl_unary_op_test { test_helpers::test_lanes! { fn $fn() { test_helpers::test_unary_elementwise( - <$vector as core::ops::$trait>::$fn, - $scalar_fn, - |_| true, + &<$vector as core::ops::$trait>::$fn, + &$scalar_fn, + &|_| true, ); } } @@ -26,42 +26,42 @@ macro_rules! impl_binary_op_test { test_helpers::test_lanes! { fn normal() { test_helpers::test_binary_elementwise( - <$vector as core::ops::$trait>::$fn, - $scalar_fn, - |_, _| true, + &<$vector as core::ops::$trait>::$fn, + &$scalar_fn, + &|_, _| true, ); } fn scalar_rhs() { test_helpers::test_binary_scalar_rhs_elementwise( - <$vector as core::ops::$trait<$scalar>>::$fn, - $scalar_fn, - |_, _| true, + &<$vector as core::ops::$trait<$scalar>>::$fn, + &$scalar_fn, + &|_, _| true, ); } fn scalar_lhs() { test_helpers::test_binary_scalar_lhs_elementwise( - <$scalar as core::ops::$trait<$vector>>::$fn, - $scalar_fn, - |_, _| true, + &<$scalar as core::ops::$trait<$vector>>::$fn, + &$scalar_fn, + &|_, _| true, ); } fn assign() { test_helpers::test_binary_elementwise( - |mut a, b| { <$vector as core::ops::$trait_assign>::$fn_assign(&mut a, b); a }, - $scalar_fn, - |_, _| true, - ) + &|mut a, b| { <$vector as core::ops::$trait_assign>::$fn_assign(&mut a, b); a }, + &$scalar_fn, + &|_, _| true, + ); } fn assign_scalar_rhs() { test_helpers::test_binary_scalar_rhs_elementwise( - |mut a, b| { <$vector as core::ops::$trait_assign<$scalar>>::$fn_assign(&mut a, b); a }, - $scalar_fn, - |_, _| true, - ) + &|mut a, b| { <$vector as core::ops::$trait_assign<$scalar>>::$fn_assign(&mut a, b); a }, + &$scalar_fn, + &|_, _| true, + ); } } } @@ -79,41 +79,41 @@ macro_rules! impl_binary_checked_op_test { test_helpers::test_lanes! { fn normal() { test_helpers::test_binary_elementwise( - <$vector as core::ops::$trait>::$fn, - $scalar_fn, - |x, y| x.iter().zip(y.iter()).all(|(x, y)| $check_fn(*x, *y)), + &<$vector as core::ops::$trait>::$fn, + &$scalar_fn, + &|x, y| x.iter().zip(y.iter()).all(|(x, y)| $check_fn(*x, *y)), ); } fn scalar_rhs() { test_helpers::test_binary_scalar_rhs_elementwise( - <$vector as core::ops::$trait<$scalar>>::$fn, - $scalar_fn, - |x, y| x.iter().all(|x| $check_fn(*x, y)), + &<$vector as core::ops::$trait<$scalar>>::$fn, + &$scalar_fn, + &|x, y| x.iter().all(|x| $check_fn(*x, y)), ); } fn scalar_lhs() { test_helpers::test_binary_scalar_lhs_elementwise( - <$scalar as core::ops::$trait<$vector>>::$fn, - $scalar_fn, - |x, y| y.iter().all(|y| $check_fn(x, *y)), + &<$scalar as core::ops::$trait<$vector>>::$fn, + &$scalar_fn, + &|x, y| y.iter().all(|y| $check_fn(x, *y)), ); } fn assign() { test_helpers::test_binary_elementwise( - |mut a, b| { <$vector as core::ops::$trait_assign>::$fn_assign(&mut a, b); a }, - $scalar_fn, - |x, y| x.iter().zip(y.iter()).all(|(x, y)| $check_fn(*x, *y)), + &|mut a, b| { <$vector as core::ops::$trait_assign>::$fn_assign(&mut a, b); a }, + &$scalar_fn, + &|x, y| x.iter().zip(y.iter()).all(|(x, y)| $check_fn(*x, *y)), ) } fn assign_scalar_rhs() { test_helpers::test_binary_scalar_rhs_elementwise( - |mut a, b| { <$vector as core::ops::$trait_assign<$scalar>>::$fn_assign(&mut a, b); a }, - $scalar_fn, - |x, y| x.iter().all(|x| $check_fn(*x, y)), + &|mut a, b| { <$vector as core::ops::$trait_assign<$scalar>>::$fn_assign(&mut a, b); a }, + &$scalar_fn, + &|x, y| x.iter().all(|x| $check_fn(*x, y)), ) } } @@ -133,9 +133,9 @@ macro_rules! impl_signed_tests { test_helpers::test_lanes! { fn neg() { test_helpers::test_unary_elementwise( - as core::ops::Neg>::neg, - ::neg, - |x| !x.contains(&Scalar::MIN), + & as core::ops::Neg>::neg, + &::neg, + &|x| !x.contains(&Scalar::MIN), ); } } diff --git a/crates/test_helpers/src/lib.rs b/crates/test_helpers/src/lib.rs index 77dafe38a10a..134b4073a4e2 100644 --- a/crates/test_helpers/src/lib.rs +++ b/crates/test_helpers/src/lib.rs @@ -42,14 +42,14 @@ impl DefaultStrategy } pub fn test_1( - f: impl Fn(A) -> proptest::test_runner::TestCaseResult, + f: &dyn Fn(A) -> proptest::test_runner::TestCaseResult, ) { let mut runner = proptest::test_runner::TestRunner::default(); runner.run(&A::default_strategy(), f).unwrap(); } pub fn test_2( - f: impl Fn(A, B) -> proptest::test_runner::TestCaseResult, + f: &dyn Fn(A, B) -> proptest::test_runner::TestCaseResult, ) { let mut runner = proptest::test_runner::TestRunner::default(); runner @@ -59,17 +59,18 @@ pub fn test_2( - fv: impl Fn(Vector) -> VectorResult, - fs: impl Fn(Scalar) -> ScalarResult, - check: impl Fn([Scalar; LANES]) -> bool, + fv: &dyn Fn(Vector) -> VectorResult, + fs: &dyn Fn(Scalar) -> ScalarResult, + check: &dyn Fn([Scalar; LANES]) -> bool, ) where Scalar: Copy + Default + core::fmt::Debug + DefaultStrategy, ScalarResult: Copy + Default + biteq::BitEq + core::fmt::Debug + DefaultStrategy, Vector: Into<[Scalar; LANES]> + From<[Scalar; LANES]> + Copy, VectorResult: Into<[ScalarResult; LANES]> + From<[ScalarResult; LANES]> + Copy, { - test_1(|x: [Scalar; LANES]| { + test_1(&|x: [Scalar; LANES]| { proptest::prop_assume!(check(x)); let result_1: [ScalarResult; LANES] = fv(x.into()).into(); let result_2: [ScalarResult; LANES] = { @@ -84,6 +85,7 @@ pub fn test_unary_elementwise( - fv: impl Fn(Vector1, Vector2) -> VectorResult, - fs: impl Fn(Scalar1, Scalar2) -> ScalarResult, - check: impl Fn([Scalar1; LANES], [Scalar2; LANES]) -> bool, + fv: &dyn Fn(Vector1, Vector2) -> VectorResult, + fs: &dyn Fn(Scalar1, Scalar2) -> ScalarResult, + check: &dyn Fn([Scalar1; LANES], [Scalar2; LANES]) -> bool, ) where Scalar1: Copy + Default + core::fmt::Debug + DefaultStrategy, Scalar2: Copy + Default + core::fmt::Debug + DefaultStrategy, @@ -104,7 +106,7 @@ pub fn test_binary_elementwise< Vector2: Into<[Scalar2; LANES]> + From<[Scalar2; LANES]> + Copy, VectorResult: Into<[ScalarResult; LANES]> + From<[ScalarResult; LANES]> + Copy, { - test_2(|x: [Scalar1; LANES], y: [Scalar2; LANES]| { + test_2(&|x: [Scalar1; LANES], y: [Scalar2; LANES]| { proptest::prop_assume!(check(x, y)); let result_1: [ScalarResult; LANES] = fv(x.into(), y.into()).into(); let result_2: [ScalarResult; LANES] = { @@ -119,6 +121,7 @@ pub fn test_binary_elementwise< }); } +#[inline(never)] pub fn test_binary_scalar_rhs_elementwise< Scalar1, Scalar2, @@ -127,9 +130,9 @@ pub fn test_binary_scalar_rhs_elementwise< VectorResult, const LANES: usize, >( - fv: impl Fn(Vector, Scalar2) -> VectorResult, - fs: impl Fn(Scalar1, Scalar2) -> ScalarResult, - check: impl Fn([Scalar1; LANES], Scalar2) -> bool, + fv: &dyn Fn(Vector, Scalar2) -> VectorResult, + fs: &dyn Fn(Scalar1, Scalar2) -> ScalarResult, + check: &dyn Fn([Scalar1; LANES], Scalar2) -> bool, ) where Scalar1: Copy + Default + core::fmt::Debug + DefaultStrategy, Scalar2: Copy + Default + core::fmt::Debug + DefaultStrategy, @@ -137,7 +140,7 @@ pub fn test_binary_scalar_rhs_elementwise< Vector: Into<[Scalar1; LANES]> + From<[Scalar1; LANES]> + Copy, VectorResult: Into<[ScalarResult; LANES]> + From<[ScalarResult; LANES]> + Copy, { - test_2(|x: [Scalar1; LANES], y: Scalar2| { + test_2(&|x: [Scalar1; LANES], y: Scalar2| { proptest::prop_assume!(check(x, y)); let result_1: [ScalarResult; LANES] = fv(x.into(), y).into(); let result_2: [ScalarResult; LANES] = { @@ -152,6 +155,7 @@ pub fn test_binary_scalar_rhs_elementwise< }); } +#[inline(never)] pub fn test_binary_scalar_lhs_elementwise< Scalar1, Scalar2, @@ -160,9 +164,9 @@ pub fn test_binary_scalar_lhs_elementwise< VectorResult, const LANES: usize, >( - fv: impl Fn(Scalar1, Vector) -> VectorResult, - fs: impl Fn(Scalar1, Scalar2) -> ScalarResult, - check: impl Fn(Scalar1, [Scalar2; LANES]) -> bool, + fv: &dyn Fn(Scalar1, Vector) -> VectorResult, + fs: &dyn Fn(Scalar1, Scalar2) -> ScalarResult, + check: &dyn Fn(Scalar1, [Scalar2; LANES]) -> bool, ) where Scalar1: Copy + Default + core::fmt::Debug + DefaultStrategy, Scalar2: Copy + Default + core::fmt::Debug + DefaultStrategy, @@ -170,7 +174,7 @@ pub fn test_binary_scalar_lhs_elementwise< Vector: Into<[Scalar2; LANES]> + From<[Scalar2; LANES]> + Copy, VectorResult: Into<[ScalarResult; LANES]> + From<[ScalarResult; LANES]> + Copy, { - test_2(|x: Scalar1, y: [Scalar2; LANES]| { + test_2(&|x: Scalar1, y: [Scalar2; LANES]| { proptest::prop_assume!(check(x, y)); let result_1: [ScalarResult; LANES] = fv(x, y.into()).into(); let result_2: [ScalarResult; LANES] = {