Skip to content

Commit b506e3e

Browse files
Renovate for Edition 2021
In a still-future edition, `unsafe_op_in_unsafe_fn` may error. Let's get ahead of that.
1 parent afd7c5a commit b506e3e

File tree

6 files changed

+17
-10
lines changed

6 files changed

+17
-10
lines changed

crates/core_simd/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "core_simd"
33
version = "0.1.0"
4-
edition = "2018"
4+
edition = "2021"
55
homepage = "https://github.com/rust-lang/portable-simd"
66
repository = "https://github.com/rust-lang/portable-simd"
77
keywords = ["core", "simd", "intrinsics"]

crates/core_simd/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
)]
1212
#![cfg_attr(feature = "generic_const_exprs", feature(generic_const_exprs))]
1313
#![warn(missing_docs)]
14+
#![deny(unsafe_op_in_unsafe_fn)]
1415
#![unstable(feature = "portable_simd", issue = "86656")]
1516
//! Portable SIMD module.
1617

crates/core_simd/src/masks.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ where
118118
/// All lanes must be either 0 or -1.
119119
#[inline]
120120
pub unsafe fn from_int_unchecked(value: Simd<T, LANES>) -> Self {
121-
Self(mask_impl::Mask::from_int_unchecked(value))
121+
unsafe { Self(mask_impl::Mask::from_int_unchecked(value)) }
122122
}
123123

124124
/// Converts a vector of integers to a mask, where 0 represents `false` and -1
@@ -145,7 +145,7 @@ where
145145
/// `lane` must be less than `LANES`.
146146
#[inline]
147147
pub unsafe fn test_unchecked(&self, lane: usize) -> bool {
148-
self.0.test_unchecked(lane)
148+
unsafe { self.0.test_unchecked(lane) }
149149
}
150150

151151
/// Tests the value of the specified lane.
@@ -164,7 +164,9 @@ where
164164
/// `lane` must be less than `LANES`.
165165
#[inline]
166166
pub unsafe fn set_unchecked(&mut self, lane: usize, value: bool) {
167-
self.0.set_unchecked(lane, value);
167+
unsafe {
168+
self.0.set_unchecked(lane, value);
169+
}
168170
}
169171

170172
/// Sets the value of the specified lane.

crates/core_simd/src/masks/bitmask.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ where
9393

9494
#[inline]
9595
pub unsafe fn set_unchecked(&mut self, lane: usize, value: bool) {
96-
self.0.as_mut()[lane / 8] ^= ((value ^ self.test_unchecked(lane)) as u8) << (lane % 8)
96+
unsafe {
97+
self.0.as_mut()[lane / 8] ^= ((value ^ self.test_unchecked(lane)) as u8) << (lane % 8)
98+
}
9799
}
98100

99101
#[inline]
@@ -112,9 +114,11 @@ where
112114
core::mem::size_of::<<LaneCount::<LANES> as SupportedLaneCount>::BitMask>(),
113115
core::mem::size_of::<<LaneCount::<LANES> as SupportedLaneCount>::IntBitMask>(),
114116
);
115-
let mask: <LaneCount<LANES> as SupportedLaneCount>::IntBitMask =
116-
intrinsics::simd_bitmask(value);
117-
Self(core::mem::transmute_copy(&mask), PhantomData)
117+
unsafe {
118+
let mask: <LaneCount<LANES> as SupportedLaneCount>::IntBitMask =
119+
intrinsics::simd_bitmask(value);
120+
Self(core::mem::transmute_copy(&mask), PhantomData)
121+
}
118122
}
119123

120124
#[cfg(feature = "generic_const_exprs")]

crates/core_simd/src/round.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ macro_rules! implement {
6161
/// * Be representable in the return type, after truncating off its fractional part
6262
#[inline]
6363
pub unsafe fn to_int_unchecked(self) -> Simd<$int_type, LANES> {
64-
intrinsics::simd_cast(self)
64+
unsafe { intrinsics::simd_cast(self) }
6565
}
6666

6767
/// Creates a floating-point vector from an integer vector. Rounds values that are

crates/test_helpers/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "test_helpers"
33
version = "0.1.0"
4-
edition = "2018"
4+
edition = "2021"
55
publish = false
66

77
[dependencies.proptest]

0 commit comments

Comments
 (0)