Skip to content

Commit

Permalink
attempt to fix wasm const fn
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Oct 25, 2024
1 parent 0669fa8 commit b7339dc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
7 changes: 2 additions & 5 deletions crates/core_arch/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
sha512_sm_x86,
x86_amx_intrinsics,
f16,
rustc_allow_const_fn_unstable
rustc_allow_const_fn_unstable,
wasm_simd_const_internals
)]
#![cfg_attr(test, feature(test, abi_vectorcall, stdarch_internal))]
#![deny(clippy::missing_inline_in_public_items)]
Expand Down Expand Up @@ -73,10 +74,6 @@
stdarch_loongarch_feature_detection
)
)]
#![cfg_attr(
any(target_arch = "wasm32", target_arch = "wasm64", doc),
feature(wasm_simd_const_internals)
)]

#[cfg(test)]
#[macro_use]
Expand Down
3 changes: 3 additions & 0 deletions crates/core_arch/src/simd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ macro_rules! simd_ty {
#[allow(clippy::use_self)]
impl $id {
#[inline(always)]
#[rustc_const_unstable(feature = "wasm_simd_const_internals", issue = "none")] // FIXME remove when const-stability v2 migration is done
pub(crate) const fn new($($param_name: $elem_type),*) -> Self {
$id([$($param_name),*])
}
Expand Down Expand Up @@ -52,11 +53,13 @@ macro_rules! simd_m_ty {
#[allow(clippy::use_self)]
impl $id {
#[inline(always)]
#[rustc_const_unstable(feature = "wasm_simd_const_internals", issue = "none")] // FIXME remove when const-stability v2 migration is done
const fn bool_to_internal(x: bool) -> $elem_type {
[0 as $elem_type, !(0 as $elem_type)][x as usize]
}

#[inline(always)]
#[rustc_const_unstable(feature = "wasm_simd_const_internals", issue = "none")] // FIXME remove when const-stability v2 migration is done
pub(crate) const fn new($($param_name: bool),*) -> Self {
$id([$(Self::bool_to_internal($param_name)),*])
}
Expand Down

0 comments on commit b7339dc

Please sign in to comment.