Skip to content

Commit 341d0bd

Browse files
committed
Document allowed vector lengths
1 parent 6ffafb9 commit 341d0bd

File tree

4 files changed

+9
-15
lines changed

4 files changed

+9
-15
lines changed

crates/core_simd/src/masks.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ impl_element! { isize, usize }
118118
/// The layout of this type is unspecified, and may change between platforms
119119
/// and/or Rust versions, and code should not assume that it is equivalent to
120120
/// `[T; N]`.
121+
///
122+
/// `N` cannot be 0 and may be at most 64. This limit may be increased in
123+
/// the future.
121124
#[repr(transparent)]
122125
pub struct Mask<T, const N: usize>(Simd<T, N>)
123126
where

crates/core_simd/src/simd/num/int.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -240,16 +240,9 @@ pub trait SimdInt: Copy + Sealed {
240240
macro_rules! impl_trait {
241241
{ $($ty:ident ($unsigned:ident)),* } => {
242242
$(
243-
impl<const N: usize> Sealed for Simd<$ty, N>
244-
where
243+
impl<const N: usize> Sealed for Simd<$ty, N> {}
245244

246-
{
247-
}
248-
249-
impl<const N: usize> SimdInt for Simd<$ty, N>
250-
where
251-
252-
{
245+
impl<const N: usize> SimdInt for Simd<$ty, N> {
253246
type Mask = Mask<<$ty as SimdElement>::Mask, N>;
254247
type Scalar = $ty;
255248
type Unsigned = Simd<$unsigned, N>;

crates/core_simd/src/swizzle_dyn.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,7 @@ unsafe fn transize<T, const N: usize>(
181181
f: unsafe fn(T, T) -> T,
182182
a: Simd<u8, N>,
183183
b: Simd<u8, N>,
184-
) -> Simd<u8, N>
185-
where
186-
{
184+
) -> Simd<u8, N> {
187185
// SAFETY: Same obligation to use this function as to use mem::transmute_copy.
188186
unsafe { mem::transmute_copy(&f(mem::transmute_copy(&a), mem::transmute_copy(&b))) }
189187
}
@@ -192,9 +190,7 @@ where
192190
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
193191
#[allow(unused)]
194192
#[inline(always)]
195-
fn zeroing_idxs<const N: usize>(idxs: Simd<u8, N>) -> Simd<u8, N>
196-
where
197-
{
193+
fn zeroing_idxs<const N: usize>(idxs: Simd<u8, N>) -> Simd<u8, N> {
198194
use crate::simd::{Select, cmp::SimdPartialOrd};
199195
idxs.simd_lt(Simd::splat(N as u8))
200196
.select(idxs, Simd::splat(u8::MAX))

crates/core_simd/src/vector.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ use crate::simd::{
5151
/// Thus it is sound to [`transmute`] `Simd<T, N>` to `[T; N]` and should optimize to "zero cost",
5252
/// but the reverse transmutation may require a copy the compiler cannot simply elide.
5353
///
54+
/// `N` cannot be 0 and may be at most 64. This limit may be increased in the future.
55+
///
5456
/// # ABI "Features"
5557
/// Due to Rust's safety guarantees, `Simd<T, N>` is currently passed and returned via memory,
5658
/// not SIMD registers, except as an optimization. Using `#[inline]` on functions that accept

0 commit comments

Comments
 (0)