File tree 5 files changed +12
-1
lines changed
5 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -202,17 +202,20 @@ macro_rules! impl_trait {
202
202
#[ inline]
203
203
fn to_bits( self ) -> Simd <$bits_ty, LANES > {
204
204
assert_eq!( core:: mem:: size_of:: <Self >( ) , core:: mem:: size_of:: <Self :: Bits >( ) ) ;
205
+ // Safety: transmuting between vector types is safe
205
206
unsafe { core:: mem:: transmute_copy( & self ) }
206
207
}
207
208
208
209
#[ inline]
209
210
fn from_bits( bits: Simd <$bits_ty, LANES >) -> Self {
210
211
assert_eq!( core:: mem:: size_of:: <Self >( ) , core:: mem:: size_of:: <Self :: Bits >( ) ) ;
212
+ // Safety: transmuting between vector types is safe
211
213
unsafe { core:: mem:: transmute_copy( & bits) }
212
214
}
213
215
214
216
#[ inline]
215
217
fn abs( self ) -> Self {
218
+ // Safety: `self` is a float vector
216
219
unsafe { intrinsics:: simd_fabs( self ) }
217
220
}
218
221
@@ -283,11 +286,13 @@ macro_rules! impl_trait {
283
286
284
287
#[ inline]
285
288
fn simd_min( self , other: Self ) -> Self {
289
+ // Safety: `self` and `other` are float vectors
286
290
unsafe { intrinsics:: simd_fmin( self , other) }
287
291
}
288
292
289
293
#[ inline]
290
294
fn simd_max( self , other: Self ) -> Self {
295
+ // Safety: `self` and `other` are floating point vectors
291
296
unsafe { intrinsics:: simd_fmax( self , other) }
292
297
}
293
298
Original file line number Diff line number Diff line change 12
12
#![ cfg_attr( feature = "generic_const_exprs" , feature( generic_const_exprs) ) ]
13
13
#![ cfg_attr( feature = "generic_const_exprs" , allow( incomplete_features) ) ]
14
14
#![ warn( missing_docs) ]
15
- #![ deny( unsafe_op_in_unsafe_fn) ]
15
+ #![ deny( unsafe_op_in_unsafe_fn, clippy :: undocumented_unsafe_blocks ) ]
16
16
#![ unstable( feature = "portable_simd" , issue = "86656" ) ]
17
17
//! Portable SIMD module.
18
18
Original file line number Diff line number Diff line change 33
33
34
34
macro_rules! unsafe_base {
35
35
( $lhs: ident, $rhs: ident, { $simd_call: ident} , $( $_: tt) * ) => {
36
+ // Safety: $lhs and $rhs are vectors
36
37
unsafe { $crate:: simd:: intrinsics:: $simd_call( $lhs, $rhs) }
37
38
} ;
38
39
}
@@ -49,6 +50,7 @@ macro_rules! unsafe_base {
49
50
macro_rules! wrap_bitshift {
50
51
( $lhs: ident, $rhs: ident, { $simd_call: ident} , $int: ident) => {
51
52
#[ allow( clippy:: suspicious_arithmetic_impl) ]
53
+ // Safety: $lhs and the bitand result are vectors
52
54
unsafe {
53
55
$crate:: simd:: intrinsics:: $simd_call(
54
56
$lhs,
@@ -91,6 +93,7 @@ macro_rules! int_divrem_guard {
91
93
// Nice base case to make it easy to const-fold away the other branch.
92
94
$rhs
93
95
} ;
96
+ // Safety: $lhs and rhs are vectors
94
97
unsafe { $crate:: simd:: intrinsics:: $simd_call( $lhs, rhs) }
95
98
}
96
99
} ;
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ macro_rules! neg {
14
14
#[ inline]
15
15
#[ must_use = "operator returns a new vector without mutating the input" ]
16
16
fn neg( self ) -> Self :: Output {
17
+ // Safety: `self` is a signed vector
17
18
unsafe { intrinsics:: simd_neg( self ) }
18
19
}
19
20
} ) *
Original file line number Diff line number Diff line change @@ -30,6 +30,8 @@ macro_rules! implement {
30
30
$type: FloatToInt <I >,
31
31
I : SimdElement ,
32
32
{
33
+ // Safety: `self` is a vector, and `FloatToInt` ensures the type can be casted to
34
+ // an integer.
33
35
unsafe { intrinsics:: simd_cast( self ) }
34
36
}
35
37
}
You can’t perform that action at this time.
0 commit comments