Skip to content

Commit 20c7dc2

Browse files
Fix various lints
Mostly allowing correct mathematical operations and fixing some pointer casts to clippy's preferences.
1 parent bb73f78 commit 20c7dc2

File tree

14 files changed

+65
-37
lines changed

14 files changed

+65
-37
lines changed

examples/stencil/src/simd.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ pub(crate) fn step_x8(
3636

3737
let sum = {
3838
let i = i as i32;
39-
(a_cur!(i, 0, 0)
39+
a_cur!(i, 0, 0)
4040
+ a_cur!(-i, 0, 0)
4141
+ a_cur!(0, i, 0)
4242
+ a_cur!(0, -i, 0)
4343
+ a_cur!(0, 0, i)
44-
+ a_cur!(0, 0, -i))
44+
+ a_cur!(0, 0, -i)
4545
};
4646

4747
div = coef.mul_adde(sum, div);

src/api/bit_manip.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ macro_rules! impl_bit_manip {
3737
paste::item_with_macros! {
3838
#[allow(overflowing_literals)]
3939
pub mod [<$id _bit_manip>] {
40+
#![allow(const_item_mutation)]
4041
use super::*;
4142

4243
const LANE_WIDTH: usize = mem::size_of::<$elem_ty>() * 8;

src/api/default.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ macro_rules! impl_default {
1212
test_if!{
1313
$test_tt:
1414
paste::item! {
15+
// Comparisons use integer casts within mantissa^1 range.
16+
#[allow(clippy::float_cmp)]
1517
pub mod [<$id _default>] {
1618
use super::*;
1719
#[cfg_attr(not(target_arch = "wasm32"), test)] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]

src/api/from/from_array.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ macro_rules! impl_from_array {
5656
test_if! {
5757
$test_tt:
5858
paste::item! {
59+
// Comparisons use integer casts within mantissa^1 range.
60+
#[allow(clippy::float_cmp)]
5961
mod [<$id _from>] {
6062
use super::*;
6163
#[test]

src/api/hash.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ macro_rules! impl_hash {
3636
let mut v_hash = a_hash.clone();
3737
a.hash(&mut a_hash);
3838

39+
// Integer within mantissa^1 range.
40+
#[allow(clippy::float_cmp)]
3941
let v = $id::splat(42 as $elem_ty);
4042
v.hash(&mut v_hash);
4143
assert_eq!(a_hash.finish(), v_hash.finish());

src/api/minimal/iuf.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ macro_rules! impl_minimal_iuf {
101101
test_if!{
102102
$test_tt:
103103
paste::item! {
104+
// Comparisons use integer casts within mantissa^1 range.
105+
#[allow(clippy::float_cmp)]
104106
pub mod [<$id _minimal>] {
105107
use super::*;
106108
#[cfg_attr(not(target_arch = "wasm32"), test)]

src/api/minimal/ptr.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -550,11 +550,7 @@ macro_rules! impl_minimal_p {
550550
];
551551

552552
for i in 0..$elem_count {
553-
let ptr = unsafe {
554-
crate::mem::transmute(
555-
&values[i] as *const i32
556-
)
557-
};
553+
let ptr = &values[i] as *const i32 as *mut i32;
558554
vec = vec.replace(i, ptr);
559555
array[i] = ptr;
560556
}
@@ -1025,11 +1021,7 @@ macro_rules! impl_minimal_p {
10251021
];
10261022

10271023
for i in 0..$elem_count {
1028-
let ptr = unsafe {
1029-
crate::mem::transmute(
1030-
&values[i] as *const i32
1031-
)
1032-
};
1024+
let ptr = &values[i] as *const i32 as *mut i32;
10331025
vec = vec.replace(i, ptr);
10341026
array[i] = ptr;
10351027
}

src/api/ptr/gather_scatter.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ macro_rules! impl_ptr_read {
4949
let mut ptr = $id::<i32>::null();
5050

5151
for i in 0..$elem_count {
52-
ptr = ptr.replace(i, unsafe {
53-
crate::mem::transmute(&v[i] as *const i32)
54-
});
52+
ptr = ptr.replace(i,
53+
&v[i] as *const i32 as *mut i32
54+
);
5555
}
5656

5757
// all mask elements are true:
@@ -161,7 +161,7 @@ macro_rules! impl_ptr_write {
161161
let mut ptr = $id::<i32>::null();
162162
for i in 0..$elem_count {
163163
ptr = ptr.replace(i, unsafe {
164-
crate::mem::transmute(arr.as_ptr().add(i))
164+
arr.as_ptr().add(i) as *mut i32
165165
});
166166
}
167167
// ptr = [&arr[0], &arr[1], ...]

src/api/reductions/float_arithmetic.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ macro_rules! impl_reduction_float_arithmetic {
9393
test_if! {
9494
$test_tt:
9595
paste::item! {
96+
// Comparisons use integer casts within mantissa^1 range.
97+
#[allow(clippy::float_cmp)]
9698
pub mod [<$id _reduction_float_arith>] {
9799
use super::*;
98100
fn alternating(x: usize) -> $id {
@@ -225,7 +227,7 @@ macro_rules! impl_reduction_float_arithmetic {
225227
let mut v = $id::splat(0. as $elem_ty);
226228
for i in 0..$id::lanes() {
227229
let c = if i % 2 == 0 { 1e3 } else { -1. };
228-
start *= 3.14 * c;
230+
start *= ::core::$elem_ty::consts::PI * c;
229231
scalar_reduction += start;
230232
v = v.replace(i, start);
231233
}
@@ -278,7 +280,7 @@ macro_rules! impl_reduction_float_arithmetic {
278280
let mut v = $id::splat(0. as $elem_ty);
279281
for i in 0..$id::lanes() {
280282
let c = if i % 2 == 0 { 1e3 } else { -1. };
281-
start *= 3.14 * c;
283+
start *= ::core::$elem_ty::consts::PI * c;
282284
scalar_reduction *= start;
283285
v = v.replace(i, start);
284286
}

src/api/reductions/min_max.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ macro_rules! impl_reduction_min_max {
7676
}
7777
test_if! {$test_tt:
7878
paste::item! {
79+
// Comparisons use integer casts within mantissa^1 range.
80+
#[allow(clippy::float_cmp)]
7981
pub mod [<$id _reduction_min_max>] {
8082
use super::*;
8183
#[cfg_attr(not(target_arch = "wasm32"), test)]
@@ -124,6 +126,8 @@ macro_rules! test_reduction_float_min_max {
124126
test_if!{
125127
$test_tt:
126128
paste::item! {
129+
// Comparisons use integer casts within mantissa^1 range.
130+
#[allow(clippy::float_cmp)]
127131
pub mod [<$id _reduction_min_max_nan>] {
128132
use super::*;
129133
#[cfg_attr(not(target_arch = "wasm32"), test)]

0 commit comments

Comments
 (0)