Skip to content

Commit 3bbbc4f

Browse files
committed
Workaround something going wrong with get/set in wasm
1 parent f88957f commit 3bbbc4f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

crates/core_simd/src/vector.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,11 @@ where
218218
/// `idx` must be in-bounds (`idx < N`)
219219
#[inline]
220220
unsafe fn get_inner(self, idx: usize) -> T {
221+
// FIXME: This is a workaround for a CI failure in #498
222+
if cfg!(target_family = "wasm") {
223+
return self.as_array()[idx];
224+
}
225+
221226
// SAFETY: our precondition is also that the value is in-bounds
222227
// and this type is a simd type of the correct element type.
223228
unsafe { core::intrinsics::simd::simd_extract_dyn(self, idx as u32) }
@@ -281,6 +286,13 @@ where
281286
#[inline]
282287
#[must_use = "This returns a new vector, rather than updating in-place"]
283288
unsafe fn set_inner(self, idx: usize, val: T) -> Self {
289+
// FIXME: This is a workaround for a CI failure in #498
290+
if cfg!(target_family = "wasm") {
291+
let mut temp = self;
292+
temp.as_mut_array()[idx] = val;
293+
return temp;
294+
}
295+
284296
// SAFETY: our precondition is also that the value is in-bounds
285297
// and this type is a simd type of the correct element type.
286298
unsafe { core::intrinsics::simd::simd_insert_dyn(self, idx as u32, val) }

0 commit comments

Comments
 (0)