Skip to content

Commit cbee1bd

Browse files
Fix various lints
Mostly allowing correct mathematical operations and fixing some pointer casts to clippy's preferences. Also: Remove superfluous unit return Allow mut of const temporaries Use more precise PI const Don't index in loop
1 parent ec54d1b commit cbee1bd

File tree

16 files changed

+67
-39
lines changed

16 files changed

+67
-39
lines changed

examples/stencil/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl Data {
9797
pub fn exec<F>(&mut self, f: F)
9898
where
9999
F: Fn(i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32,
100-
&[f32; 4], &[f32], &mut [f32], &mut [f32]) -> (),
100+
&[f32; 4], &[f32], &mut [f32], &mut [f32]),
101101
{
102102
f(
103103
self.t.0, self.t.1,

examples/stencil/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::env;
88
fn run<F>(name: &str, f: F)
99
where
1010
F: Fn(i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32,
11-
&[f32; 4], &[f32], &mut [f32], &mut [f32]) -> (),
11+
&[f32; 4], &[f32], &mut [f32], &mut [f32]),
1212
{
1313
let mut d = Data::benchmark();
1414
let t = time::Duration::span(move || d.exec(f));

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], ...]

0 commit comments

Comments
 (0)