diff --git a/crates/core_simd/Cargo.toml b/crates/core_simd/Cargo.toml index 26cc65a8687..6044eabcd14 100644 --- a/crates/core_simd/Cargo.toml +++ b/crates/core_simd/Cargo.toml @@ -9,6 +9,10 @@ keywords = ["core", "simd", "intrinsics"] categories = ["hardware-support", "no-std"] license = "MIT OR Apache-2.0" +[features] +default = ["std"] +std = [] + [target.'cfg(target_arch = "wasm32")'.dev-dependencies.wasm-bindgen] version = "0.2" diff --git a/crates/core_simd/src/intrinsics.rs b/crates/core_simd/src/intrinsics.rs index 4ea38376348..213ebff3df4 100644 --- a/crates/core_simd/src/intrinsics.rs +++ b/crates/core_simd/src/intrinsics.rs @@ -41,9 +41,11 @@ extern "platform-intrinsic" { pub(crate) fn simd_cast(x: T) -> U; // floor + #[cfg(feature = "std")] pub(crate) fn simd_floor(x: T) -> T; // ceil + #[cfg(feature = "std")] pub(crate) fn simd_ceil(x: T) -> T; pub(crate) fn simd_eq(x: T, y: T) -> U; diff --git a/crates/core_simd/src/round.rs b/crates/core_simd/src/round.rs index ee232e2b222..dc37130a8ce 100644 --- a/crates/core_simd/src/round.rs +++ b/crates/core_simd/src/round.rs @@ -7,6 +7,7 @@ macro_rules! implement { Self: crate::LanesAtMost64, { /// Returns the largest integer less than or equal to each lane. + #[cfg(feature = "std")] #[must_use = "method returns a new vector and does not mutate the original value"] #[inline] pub fn floor(self) -> Self { @@ -14,6 +15,7 @@ macro_rules! implement { } /// Returns the smallest integer greater than or equal to each lane. + #[cfg(feature = "std")] #[must_use = "method returns a new vector and does not mutate the original value"] #[inline] pub fn ceil(self) -> Self { diff --git a/crates/core_simd/tests/ops_macros.rs b/crates/core_simd/tests/ops_macros.rs index 58e80a8f277..8e0b9626861 100644 --- a/crates/core_simd/tests/ops_macros.rs +++ b/crates/core_simd/tests/ops_macros.rs @@ -265,15 +265,8 @@ macro_rules! impl_float_tests { impl_binary_op_test!(Vector, Scalar, Div::div, DivAssign::div_assign); impl_binary_op_test!(Vector, Scalar, Rem::rem, RemAssign::rem_assign); + #[cfg(feature = "std")] test_helpers::test_lanes! { - fn abs() { - test_helpers::test_unary_elementwise( - &Vector::::abs, - &Scalar::abs, - &|_| true, - ) - } - fn ceil() { test_helpers::test_unary_elementwise( &Vector::::ceil, @@ -289,6 +282,16 @@ macro_rules! impl_float_tests { &|_| true, ) } + } + + test_helpers::test_lanes! { + fn abs() { + test_helpers::test_unary_elementwise( + &Vector::::abs, + &Scalar::abs, + &|_| true, + ) + } fn round_from_int() { test_helpers::test_unary_elementwise(