@@ -156,9 +156,9 @@ where
156
156
/// assert_eq!(v.as_array(), &[0, 1, 2, 3]);
157
157
/// ```
158
158
pub const fn as_array ( & self ) -> & [ T ; N ] {
159
- // SAFETY: Transmuting between `Simd<T, N>` and `[T; N]`
160
- // is always valid and `Simd<T, N>` never has a lower alignment
161
- // than ` [T; N]`.
159
+ // SAFETY: `Simd<T, N>` is just an overaligned `[T; N]` with
160
+ // potential padding at the end, so pointer casting to a
161
+ // `& [T; N]` is safe .
162
162
//
163
163
// NOTE: This deliberately doesn't just use `&self.0`, see the comment
164
164
// on the struct definition for details.
@@ -167,9 +167,9 @@ where
167
167
168
168
/// Returns a mutable array reference containing the entire SIMD vector.
169
169
pub fn as_mut_array ( & mut self ) -> & mut [ T ; N ] {
170
- // SAFETY: Transmuting between `Simd<T, N>` and `[T; N]`
171
- // is always valid and `Simd<T, N>` never has a lower alignment
172
- // than ` [T; N]`.
170
+ // SAFETY: `Simd<T, N>` is just an overaligned `[T; N]` with
171
+ // potential padding at the end, so pointer casting to a
172
+ // `&mut [T; N]` is safe .
173
173
//
174
174
// NOTE: This deliberately doesn't just use `&mut self.0`, see the comment
175
175
// on the struct definition for details.
0 commit comments