Skip to content

Commit 1cee930

Browse files
committed
Fix generic_const_exprs feature
1 parent b7fea94 commit 1cee930

File tree

5 files changed

+15
-4
lines changed

5 files changed

+15
-4
lines changed

crates/core_simd/src/masks.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
mod mask_impl;
1414

1515
mod to_bitmask;
16-
pub use to_bitmask::{ToBitMask, ToBitMaskArray};
16+
pub use to_bitmask::ToBitMask;
1717

1818
#[cfg(feature = "generic_const_exprs")]
19-
pub use to_bitmask::bitmask_len;
19+
pub use to_bitmask::{bitmask_len, ToBitMaskArray};
2020

2121
use crate::simd::{intrinsics, LaneCount, Simd, SimdElement, SimdPartialEq, SupportedLaneCount};
2222
use core::cmp::Ordering;

crates/core_simd/src/masks/bitmask.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![allow(unused_imports)]
22
use super::MaskElement;
33
use crate::simd::intrinsics;
4-
use crate::simd::{LaneCount, Simd, SupportedLaneCount, ToBitMask, ToBitMaskArray};
4+
use crate::simd::{LaneCount, Simd, SupportedLaneCount, ToBitMask};
55
use core::marker::PhantomData;
66

77
/// A mask where each lane is represented by a single bit.
@@ -115,6 +115,7 @@ where
115115
unsafe { Self(intrinsics::simd_bitmask(value), PhantomData) }
116116
}
117117

118+
#[cfg(feature = "generic_const_exprs")]
118119
#[inline]
119120
#[must_use = "method returns a new array and does not mutate the original value"]
120121
pub fn to_bitmask_array<const N: usize>(self) -> [u8; N] {
@@ -124,6 +125,7 @@ where
124125
unsafe { core::mem::transmute_copy(&self.0) }
125126
}
126127

128+
#[cfg(feature = "generic_const_exprs")]
127129
#[inline]
128130
#[must_use = "method returns a new mask and does not mutate the original value"]
129131
pub fn from_bitmask_array<const N: usize>(bitmask: [u8; N]) -> Self {

crates/core_simd/src/masks/full_masks.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
33
use super::MaskElement;
44
use crate::simd::intrinsics;
5-
use crate::simd::{LaneCount, Simd, SupportedLaneCount, ToBitMask, ToBitMaskArray};
5+
use crate::simd::{LaneCount, Simd, SupportedLaneCount, ToBitMask};
6+
7+
#[cfg(feature = "generic_const_exprs")]
8+
use crate::simd::ToBitMaskArray;
69

710
#[repr(transparent)]
811
pub struct Mask<T, const LANES: usize>(Simd<T, LANES>)
@@ -139,6 +142,7 @@ where
139142
unsafe { Mask(intrinsics::simd_cast(self.0)) }
140143
}
141144

145+
#[cfg(feature = "generic_const_exprs")]
142146
#[inline]
143147
#[must_use = "method returns a new array and does not mutate the original value"]
144148
pub fn to_bitmask_array<const N: usize>(self) -> [u8; N]
@@ -171,6 +175,7 @@ where
171175
}
172176
}
173177

178+
#[cfg(feature = "generic_const_exprs")]
174179
#[inline]
175180
#[must_use = "method returns a new mask and does not mutate the original value"]
176181
pub fn from_bitmask_array<const N: usize>(mut bitmask: [u8; N]) -> Self

crates/core_simd/src/masks/to_bitmask.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ pub unsafe trait ToBitMask: Sealed {
3838
/// # Safety
3939
/// This trait is `unsafe` and sealed, since the `BYTES` value must match the number of lanes in
4040
/// the mask.
41+
#[cfg(feature = "generic_const_exprs")]
4142
pub unsafe trait ToBitMaskArray: Sealed {
4243
/// The length of the bitmask array.
4344
const BYTES: usize;
@@ -78,10 +79,12 @@ impl_integer_intrinsic! {
7879
}
7980

8081
/// Returns the minimum numnber of bytes in a bitmask with `lanes` lanes.
82+
#[cfg(feature = "generic_const_exprs")]
8183
pub const fn bitmask_len(lanes: usize) -> usize {
8284
(lanes + 7) / 8
8385
}
8486

87+
#[cfg(feature = "generic_const_exprs")]
8588
unsafe impl<T: MaskElement, const LANES: usize> ToBitMaskArray for Mask<T, LANES>
8689
where
8790
LaneCount<LANES>: SupportedLaneCount,

crates/core_simd/tests/masks.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ macro_rules! test_mask_api {
123123
cast_impl::<isize>();
124124
}
125125

126+
#[cfg(feature = "generic_const_exprs")]
126127
#[test]
127128
fn roundtrip_bitmask_array_conversion() {
128129
use core_simd::ToBitMaskArray;

0 commit comments

Comments
 (0)