diff --git a/Cargo.toml b/Cargo.toml index ca3f6a0..1cde154 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -97,7 +97,7 @@ latest_stable_rust = [ # ALL FEATURES BELOW THIS ARE NOT SEMVER SUPPORTED! TEMPORARY ONLY! # Enable support for `std::simd` types. -nightly_portable_simd = [] +nightly_portable_simd = ["rustversion"] # Enable support for unstable `std::arch` types (such as the AVX512 types). nightly_stdsimd = [] # Enable `f16` and `f128` @@ -108,6 +108,7 @@ nightly_docs = [] [dependencies] bytemuck_derive = { version = "1.10.2", path = "derive", optional = true } +rustversion = { version = "1.0.22", optional = true } [lints.rust] unexpected_cfgs = { level = "deny", check-cfg = [ diff --git a/src/pod.rs b/src/pod.rs index 846f281..330f722 100644 --- a/src/pod.rs +++ b/src/pod.rs @@ -143,6 +143,7 @@ impl_unsafe_marker_for_simd!( } ); +#[rustversion::before(2026-01-27)] // See https://github.com/Lokathor/bytemuck/issues/343 #[cfg(feature = "nightly_portable_simd")] #[cfg_attr( feature = "nightly_docs", @@ -155,6 +156,18 @@ where { } +#[rustversion::since(2026-01-27)] // See https://github.com/Lokathor/bytemuck/issues/343 +#[cfg(feature = "nightly_portable_simd")] +#[cfg_attr( + feature = "nightly_docs", + doc(cfg(feature = "nightly_portable_simd")) +)] +unsafe impl Pod for core::simd::Simd +where + T: core::simd::SimdElement + Pod, +{ +} + impl_unsafe_marker_for_simd!( #[cfg(all(target_arch = "x86", feature = "avx512_simd"))] unsafe impl Pod for x86::{ diff --git a/src/zeroable.rs b/src/zeroable.rs index d88ba0f..186c567 100644 --- a/src/zeroable.rs +++ b/src/zeroable.rs @@ -222,6 +222,7 @@ impl_unsafe_marker_for_simd!( } ); +#[rustversion::before(2026-01-27)] // See https://github.com/Lokathor/bytemuck/issues/343 #[cfg(feature = "nightly_portable_simd")] #[cfg_attr( feature = "nightly_docs", @@ -234,6 +235,18 @@ where { } +#[rustversion::since(2026-01-27)] // See https://github.com/Lokathor/bytemuck/issues/343 +#[cfg(feature = "nightly_portable_simd")] +#[cfg_attr( + feature = "nightly_docs", + doc(cfg(feature = "nightly_portable_simd")) +)] +unsafe impl Zeroable for core::simd::Simd +where + T: core::simd::SimdElement + Zeroable, +{ +} + impl_unsafe_marker_for_simd!( #[cfg(all(target_arch = "x86", feature = "avx512_simd"))] unsafe impl Zeroable for x86::{