Skip to content

Commit d68cf47

Browse files
committed
Remove workarounds for rust-lang/rust#60637
1 parent 7738477 commit d68cf47

File tree

2 files changed

+4
-34
lines changed

2 files changed

+4
-34
lines changed

crates/core_arch/src/macros.rs

+1-14
Original file line numberDiff line numberDiff line change
@@ -94,25 +94,15 @@ macro_rules! types {
9494
/// so use this internal helper for it instead.
9595
#[inline(always)]
9696
$v fn splat(value: $elem_type) -> $name {
97-
#[derive(Copy, Clone)]
98-
#[repr(simd)]
99-
struct JustOne([$elem_type; 1]);
100-
let one = JustOne([value]);
101-
// SAFETY: 0 is always in-bounds because we're shuffling
102-
// a simd type with exactly one element.
103-
unsafe { simd_shuffle!(one, one, [0; $len]) }
97+
$name([value; $len])
10498
}
10599

106100
/// Returns an array reference containing the entire SIMD vector.
107101
$v const fn as_array(&self) -> &[$elem_type; $len] {
108102
// SAFETY: this type is just an overaligned `[T; N]` with
109103
// potential padding at the end, so pointer casting to a
110104
// `&[T; N]` is safe.
111-
//
112-
// NOTE: This deliberately doesn't just use `&self.0` because it may soon be banned
113-
// see https://github.com/rust-lang/compiler-team/issues/838
114105
unsafe { &*(self as *const Self as *const [$elem_type; $len]) }
115-
116106
}
117107

118108
/// Returns a mutable array reference containing the entire SIMD vector.
@@ -121,9 +111,6 @@ macro_rules! types {
121111
// SAFETY: this type is just an overaligned `[T; N]` with
122112
// potential padding at the end, so pointer casting to a
123113
// `&mut [T; N]` is safe.
124-
//
125-
// NOTE: This deliberately doesn't just use `&mut self.0` because it may soon be banned
126-
// see https://github.com/rust-lang/compiler-team/issues/838
127114
unsafe { &mut *(self as *mut Self as *mut [$elem_type; $len]) }
128115
}
129116
}

crates/core_arch/src/simd.rs

+3-20
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,12 @@ macro_rules! simd_ty {
2121
pub(crate) const fn from_array(elements: [$elem_type; $len]) -> Self {
2222
$id(elements)
2323
}
24-
// FIXME: Workaround rust@60637
24+
2525
#[inline(always)]
2626
pub(crate) fn splat(value: $elem_type) -> Self {
27-
#[derive(Copy, Clone)]
28-
#[repr(simd)]
29-
struct JustOne([$elem_type; 1]);
30-
let one = JustOne([value]);
31-
// SAFETY: 0 is always in-bounds because we're shuffling
32-
// a simd type with exactly one element.
33-
unsafe { simd_shuffle!(one, one, [0; $len]) }
27+
$id([value; $len])
3428
}
3529

36-
/// Extract the element at position `index`.
37-
/// `index` is not a constant so this is not efficient!
38-
/// Use for testing only.
39-
// FIXME: Workaround rust@60637
4030
#[inline(always)]
4131
pub(crate) fn extract(&self, index: usize) -> $elem_type {
4232
self.as_array()[index]
@@ -87,16 +77,9 @@ macro_rules! simd_m_ty {
8777
$id([$(Self::bool_to_internal($param_name)),*])
8878
}
8979

90-
// FIXME: Workaround rust@60637
9180
#[inline(always)]
9281
pub(crate) fn splat(value: bool) -> Self {
93-
#[derive(Copy, Clone)]
94-
#[repr(simd)]
95-
struct JustOne([$elem_type; 1]);
96-
let one = JustOne([Self::bool_to_internal(value)]);
97-
// SAFETY: 0 is always in-bounds because we're shuffling
98-
// a simd type with exactly one element.
99-
unsafe { simd_shuffle!(one, one, [0; $len]) }
82+
$id([Self::bool_to_internal(value); $len])
10083
}
10184

10285
#[inline]

0 commit comments

Comments
 (0)