Skip to content

Commit 4d704a2

Browse files
author
Fedor Ryabinin
committed
Undo formatting of portable-simd.
1 parent 52176d3 commit 4d704a2

4 files changed

Lines changed: 44 additions & 15 deletions

File tree

library/portable-simd/crates/core_simd/src/masks.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,11 @@ where
374374
// Safety: the return value is the unsigned version of T
375375
let min_index: T = unsafe { core::mem::transmute_copy(&min_index) };
376376

377-
if min_index.eq(T::TRUE) { None } else { Some(min_index.to_usize()) }
377+
if min_index.eq(T::TRUE) {
378+
None
379+
} else {
380+
Some(min_index.to_usize())
381+
}
378382
}
379383
}
380384

@@ -441,7 +445,9 @@ where
441445
{
442446
#[inline]
443447
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
444-
f.debug_list().entries((0..N).map(|i| self.test(i))).finish()
448+
f.debug_list()
449+
.entries((0..N).map(|i| self.test(i)))
450+
.finish()
445451
}
446452
}
447453

library/portable-simd/crates/core_simd/src/masks/bitmask.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,9 @@ where
133133
pub(crate) fn from_bitmask_integer(bitmask: u64) -> Self {
134134
let mut bytes = <LaneCount<N> as SupportedLaneCount>::BitMask::default();
135135
let len = bytes.as_mut().len();
136-
bytes.as_mut().copy_from_slice(&bitmask.to_ne_bytes()[..len]);
136+
bytes
137+
.as_mut()
138+
.copy_from_slice(&bitmask.to_ne_bytes()[..len]);
137139
Self(bytes, PhantomData)
138140
}
139141

library/portable-simd/crates/core_simd/src/masks/full_masks.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,11 @@ where
162162
let bitmask: U = unsafe { core::intrinsics::simd::simd_bitmask(resized) };
163163

164164
// LLVM assumes bit order should match endianness
165-
if cfg!(target_endian = "big") { bitmask.reverse_bits(M) } else { bitmask }
165+
if cfg!(target_endian = "big") {
166+
bitmask.reverse_bits(M)
167+
} else {
168+
bitmask
169+
}
166170
}
167171

168172
#[inline]
@@ -171,7 +175,11 @@ where
171175
LaneCount<M>: SupportedLaneCount,
172176
{
173177
// LLVM assumes bit order should match endianness
174-
let bitmask = if cfg!(target_endian = "big") { bitmask.reverse_bits(M) } else { bitmask };
178+
let bitmask = if cfg!(target_endian = "big") {
179+
bitmask.reverse_bits(M)
180+
} else {
181+
bitmask
182+
};
175183

176184
// SAFETY: `mask` is the correct bitmask type for a u64 bitmask
177185
let mask: Simd<T, M> = unsafe {

library/portable-simd/crates/core_simd/src/swizzle.rs

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ pub trait Swizzle<const N: usize> {
9898
while i < N {
9999
let index = Self::INDEX[i];
100100
assert!(index as u32 as usize == index);
101-
assert!(index < M, "source element index exceeds input vector length");
101+
assert!(
102+
index < M,
103+
"source element index exceeds input vector length"
104+
);
102105
output[i] = index as u32;
103106
i += 1;
104107
}
@@ -135,7 +138,10 @@ pub trait Swizzle<const N: usize> {
135138
while i < N {
136139
let index = Self::INDEX[i];
137140
assert!(index as u32 as usize == index);
138-
assert!(index < 2 * M, "source element index exceeds input vector length");
141+
assert!(
142+
index < 2 * M,
143+
"source element index exceeds input vector length"
144+
);
139145
output[i] = index as u32;
140146
i += 1;
141147
}
@@ -385,7 +391,10 @@ where
385391
const INDEX: [usize; N] = interleave::<N>(true);
386392
}
387393

388-
(Lo::concat_swizzle(self, other), Hi::concat_swizzle(self, other))
394+
(
395+
Lo::concat_swizzle(self, other),
396+
Hi::concat_swizzle(self, other),
397+
)
389398
}
390399

391400
/// Deinterleave two vectors.
@@ -433,7 +442,10 @@ where
433442
const INDEX: [usize; N] = deinterleave::<N>(true);
434443
}
435444

436-
(Even::concat_swizzle(self, other), Odd::concat_swizzle(self, other))
445+
(
446+
Even::concat_swizzle(self, other),
447+
Odd::concat_swizzle(self, other),
448+
)
437449
}
438450

439451
/// Resize a vector.
@@ -619,7 +631,12 @@ where
619631
pub fn deinterleave(self, other: Self) -> (Self, Self) {
620632
let (even, odd) = self.to_int().deinterleave(other.to_int());
621633
// Safety: swizzles are safe for masks
622-
unsafe { (Self::from_int_unchecked(even), Self::from_int_unchecked(odd)) }
634+
unsafe {
635+
(
636+
Self::from_int_unchecked(even),
637+
Self::from_int_unchecked(odd),
638+
)
639+
}
623640
}
624641

625642
/// Resize a mask.
@@ -674,11 +691,7 @@ where
674691
}
675692

676693
#[unstable(feature = "ub_checks", issue = "none")]
677-
impl<T, const N: usize> Invariant for Mask<T, N>
678-
where
679-
T: MaskElement,
680-
LaneCount<N>: SupportedLaneCount,
681-
{
694+
impl<T, const N: usize> Invariant for Mask<T, N> where T: MaskElement, LaneCount<N>: SupportedLaneCount {
682695
fn is_safe(&self) -> bool {
683696
true // swizzles are safe for masks
684697
}

0 commit comments

Comments
 (0)