Skip to content

Commit

Permalink
Further clippy fixes
Browse files Browse the repository at this point in the history
Fixed up some new warnings created by clippy
  • Loading branch information
arduano committed Dec 5, 2024
1 parent 0891f6d commit a1a33e8
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 53 deletions.
2 changes: 1 addition & 1 deletion benches/numparse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl<'a, S: Simd> NumberParserSimd<'a, S> {
Self {
// Transmuting here is safe because we're converting from u8 to i8
// This is necessary to make loading easier below
string: unsafe { core::mem::transmute(string.as_bytes()) },
string: unsafe { core::mem::transmute::<&[u8], &[i8]>(string.as_bytes()) },

_simd: std::marker::PhantomData,
}
Expand Down
2 changes: 1 addition & 1 deletion examples/string_parse_sum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl<'a, S: Simd> NumberParserSimd<'a, S> {
Self {
// Transmuting here is safe because we're converting from u8 to i8
// This is necessary to make loading easier below
string: unsafe { core::mem::transmute(string.as_bytes()) },
string: unsafe { core::mem::transmute::<&[u8], &[i8]>(string.as_bytes()) },
_simd: std::marker::PhantomData,
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/base/iters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub struct SimdArrayIterator<'a, S: SimdBaseIo> {
index: usize,
}

impl<'a, S: SimdBaseIo> Iterator for SimdArrayIterator<'a, S> {
impl<S: SimdBaseIo> Iterator for SimdArrayIterator<'_, S> {
type Item = S::Scalar;

#[inline(always)]
Expand Down
6 changes: 1 addition & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,11 @@
//!
//! * `distance<S:Simd>` the generic version of your function
//! * `distance_compiletime` the fastest instruction set availble for the given compile time
//! feature set
//! feature set
//!
//! You may also forgo the macros if you know what you are doing, just keep in mind there are lots
//! of arcane subtleties with inlining and target_features that must be managed. See how the macros
//! expand for more detail.
#![cfg_attr(
all(target_arch = "wasm32", not(feature = "stable")),
feature(core_intrinsics)
)]
#![allow(clippy::missing_safety_doc)] // TODO: Work on the safety of functions
#![cfg_attr(all(feature = "no_std", not(test)), no_std)]
#[macro_use]
Expand Down
1 change: 1 addition & 0 deletions src/libm_ext/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(dead_code)]
#[cfg(feature = "no_std")]
mod no_std;

Expand Down
8 changes: 4 additions & 4 deletions src/ops/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ impl_op! {
impl_op! {
fn cast_i64<f64> {
for Avx2(a: __m256d) -> __m256i {
let nums_arr = core::mem::transmute::<_, [f64; 4]>(a);
let nums_arr = core::mem::transmute::<__m256d, [f64; 4]>(a);
let ceil = [
nums_arr[0].m_round() as i64,
nums_arr[1].m_round() as i64,
Expand All @@ -622,15 +622,15 @@ impl_op! {
core::mem::transmute::<_, __m256i>(ceil)
}
for Sse41(a: __m128d) -> __m128i {
let nums_arr = core::mem::transmute::<_, [f64; 2]>(a);
let nums_arr = core::mem::transmute::<__m128d, [f64; 2]>(a);
let ceil = [
nums_arr[0].m_round() as i64,
nums_arr[1].m_round() as i64,
];
core::mem::transmute::<_, __m128i>(ceil)
}
for Sse2(a: __m128d) -> __m128i {
let nums_arr = core::mem::transmute::<_, [f64; 2]>(a);
let nums_arr = core::mem::transmute::<__m128d, [f64; 2]>(a);
let ceil = [
nums_arr[0].m_round() as i64,
nums_arr[1].m_round() as i64,
Expand All @@ -641,7 +641,7 @@ impl_op! {
a.m_round() as i64
}
for Neon(a: float64x2_t) -> int64x2_t {
let nums_arr = core::mem::transmute::<_, [f64; 2]>(a);
let nums_arr = core::mem::transmute::<int64x2_t, [f64; 2]>(a);

Check failure on line 644 in src/ops/f64.rs

View workflow job for this annotation

GitHub Actions / Code Checks (formatting, clippy)

mismatched types

Check failure on line 644 in src/ops/f64.rs

View workflow job for this annotation

GitHub Actions / Arm Neon Tests

mismatched types

Check failure on line 644 in src/ops/f64.rs

View workflow job for this annotation

GitHub Actions / Arm Neon Tests

mismatched types

Check failure on line 644 in src/ops/f64.rs

View workflow job for this annotation

GitHub Actions / Code Checks (formatting, clippy)

mismatched types
let ceil = [
nums_arr[0].m_round() as i64,
nums_arr[1].m_round() as i64,
Expand Down
4 changes: 2 additions & 2 deletions src/ops/i16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ impl_op! {
arr[6] as i32,
arr[7] as i32,
];
(core::mem::transmute(a), core::mem::transmute(b))
(core::mem::transmute::<[i32; 4], __m128i>(a), core::mem::transmute::<[i32; 4], __m128i>(b))
}
for Scalar(val: i16) -> (i32, i32) {
(val as i32, 0)
Expand Down Expand Up @@ -454,7 +454,7 @@ impl_op! {
arr[6] as u16 as u32 as i32,
arr[7] as u16 as u32 as i32,
];
(core::mem::transmute(a), core::mem::transmute(b))
(core::mem::transmute::<[i32; 4], __m128i>(a), core::mem::transmute::<[i32; 4], __m128i>(b))
}
for Scalar(val: i16) -> (i32, i32) {
(val as u16 as u32 as i32, 0)
Expand Down
15 changes: 9 additions & 6 deletions src/ops/i32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ impl_op! {
_mm_mullo_epi32(a, b)
}
for Sse2(a: __m128i, b: __m128i) -> __m128i {
let a_arr = core::mem::transmute::<_, [i32; 4]>(a);
let b_arr = core::mem::transmute::<_, [i32; 4]>(b);
let a_arr = core::mem::transmute::<__m128i, [i32; 4]>(a);
let b_arr = core::mem::transmute::<__m128i, [i32; 4]>(b);
let c_arr = [
a_arr[0].wrapping_mul(b_arr[0]),
a_arr[1].wrapping_mul(b_arr[1]),
Expand Down Expand Up @@ -450,10 +450,13 @@ impl_op! {
Ops::<Sse2, i32>::extend_i64(val)
}
for Sse2(val: __m128i) -> (__m128i, __m128i) {
let arr = core::mem::transmute::<_, [i32; 4]>(val);
let arr = core::mem::transmute::<__m128i, [i32; 4]>(val);
let a = [arr[0] as i64, arr[1] as i64];
let b = [arr[2] as i64, arr[3] as i64];
(core::mem::transmute(a), core::mem::transmute(b))
(
core::mem::transmute::<[i64; 2], __m128i>(a),
core::mem::transmute::<[i64; 2], __m128i>(b)
)
}
for Scalar(val: i32) -> (i64, i64) {
(val as i64, 0)
Expand All @@ -477,10 +480,10 @@ impl_op! {
Ops::<Sse2, i32>::unsigned_extend_i64(val)
}
for Sse2(val: __m128i) -> (__m128i, __m128i) {
let arr = core::mem::transmute::<_, [i32; 4]>(val);
let arr = core::mem::transmute::<__m128i, [i32; 4]>(val);
let a = [arr[0] as u32 as u64 as i64, arr[1] as u32 as u64 as i64];
let b = [arr[2] as u32 as u64 as i64, arr[3] as u32 as u64 as i64];
(core::mem::transmute(a), core::mem::transmute(b))
(core::mem::transmute::<[i64; 2], __m128i>(a), core::mem::transmute::<[i64; 2], __m128i>(b))
}
for Scalar(val: i32) -> (i64, i64) {
(val as u32 as u64 as i64, 0)
Expand Down
22 changes: 11 additions & 11 deletions src/ops/i64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ impl_op! {
impl_op! {
fn mul<i64> {
for Avx2(a: __m256i, b: __m256i) -> __m256i {
let a_arr = core::mem::transmute::<_, [i64; 4]>(a);
let b_arr = core::mem::transmute::<_, [i64; 4]>(b);
let a_arr = core::mem::transmute::<__m256i, [i64; 4]>(a);
let b_arr = core::mem::transmute::<__m256i, [i64; 4]>(b);
let c_arr = [
a_arr[0].wrapping_mul(b_arr[0]),
a_arr[1].wrapping_mul(b_arr[1]),
Expand All @@ -54,17 +54,17 @@ impl_op! {
core::mem::transmute::<_, __m256i>(c_arr)
}
for Sse41(a: __m128i, b: __m128i) -> __m128i {
let a_arr = core::mem::transmute::<_, [i64; 2]>(a);
let b_arr = core::mem::transmute::<_, [i64; 2]>(b);
let a_arr = core::mem::transmute::<__m128i, [i64; 2]>(a);
let b_arr = core::mem::transmute::<__m128i, [i64; 2]>(b);
let c_arr = [
a_arr[0].wrapping_mul(b_arr[0]),
a_arr[1].wrapping_mul(b_arr[1]),
];
core::mem::transmute::<_, __m128i>(c_arr)
}
for Sse2(a: __m128i, b: __m128i) -> __m128i {
let a_arr = core::mem::transmute::<_, [i64; 2]>(a);
let b_arr = core::mem::transmute::<_, [i64; 2]>(b);
let a_arr = core::mem::transmute::<__m128i, [i64; 2]>(a);
let b_arr = core::mem::transmute::<__m128i, [i64; 2]>(b);
let c_arr = [
a_arr[0].wrapping_mul(b_arr[0]),
a_arr[1].wrapping_mul(b_arr[1]),
Expand All @@ -75,8 +75,8 @@ impl_op! {
a.wrapping_mul(b)
}
for Neon(a: int64x2_t, b: int64x2_t) -> int64x2_t {
let a_arr = core::mem::transmute::<_, [i64; 2]>(a);
let b_arr = core::mem::transmute::<_, [i64; 2]>(b);
let a_arr = core::mem::transmute::<int64x2_t, [i64; 2]>(a);
let b_arr = core::mem::transmute::<int64x2_t, [i64; 2]>(b);
let c_arr = [
a_arr[0].wrapping_mul(b_arr[0]),
a_arr[1].wrapping_mul(b_arr[1]),
Expand Down Expand Up @@ -430,7 +430,7 @@ impl_imm8_op! {
impl_op! {
fn cast_f64<i64> {
for Avx2(a: __m256i) -> __m256d {
let arr = core::mem::transmute::<_, [i64; 4]>(a);
let arr = core::mem::transmute::<__m256i, [i64; 4]>(a);
let result = [
arr[0] as f64,
arr[1] as f64,
Expand All @@ -440,15 +440,15 @@ impl_op! {
core::mem::transmute::<_, __m256d>(result)
}
for Sse41(a: __m128i) -> __m128d {
let arr = core::mem::transmute::<_, [i64; 2]>(a);
let arr = core::mem::transmute::<__m128i, [i64; 2]>(a);
let result = [
arr[0] as f64,
arr[1] as f64,
];
core::mem::transmute::<_, __m128d>(result)
}
for Sse2(a: __m128i) -> __m128d {
let arr = core::mem::transmute::<_, [i64; 2]>(a);
let arr = core::mem::transmute::<__m128i, [i64; 2]>(a);
let result = [
arr[0] as f64,
arr[1] as f64,
Expand Down
16 changes: 8 additions & 8 deletions src/ops/i8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,24 @@ impl_op! {
impl_op! {
fn mul<i8> {
for Avx2(a: __m256i, b: __m256i) -> __m256i {
let mut arr1 = core::mem::transmute::<_, [i8; 32]>(a);
let arr2 = core::mem::transmute::<_, [i8; 32]>(b);
let mut arr1 = core::mem::transmute::<__m256i, [i8; 32]>(a);
let arr2 = core::mem::transmute::<__m256i, [i8; 32]>(b);
for i in 0..32 {
arr1[i] = arr1[i].wrapping_mul(arr2[i]);
}
core::mem::transmute::<_, _>(arr1)
}
for Sse41(a: __m128i, b: __m128i) -> __m128i {
let mut arr1 = core::mem::transmute::<_, [i8; 16]>(a);
let arr2 = core::mem::transmute::<_, [i8; 16]>(b);
let mut arr1 = core::mem::transmute::<__m128i, [i8; 16]>(a);
let arr2 = core::mem::transmute::<__m128i, [i8; 16]>(b);
for i in 0..16 {
arr1[i] = arr1[i].wrapping_mul(arr2[i]);
}
core::mem::transmute::<_, _>(arr1)
}
for Sse2(a: __m128i, b: __m128i) -> __m128i {
let mut arr1 = core::mem::transmute::<_, [i8; 16]>(a);
let arr2 = core::mem::transmute::<_, [i8; 16]>(b);
let mut arr1 = core::mem::transmute::<__m128i, [i8; 16]>(a);
let arr2 = core::mem::transmute::<__m128i, [i8; 16]>(b);
for i in 0..16 {
arr1[i] = arr1[i].wrapping_mul(arr2[i]);
}
Expand Down Expand Up @@ -464,7 +464,7 @@ impl_op! {
arr[14] as i16,
arr[15] as i16,
];
(core::mem::transmute(a), core::mem::transmute(b))
(core::mem::transmute::<[i16; 8], __m128i>(a), core::mem::transmute::<[i16; 8], __m128i>(b))
}
for Scalar(val: i8) -> (i16, i16) {
(val as i16, 0)
Expand Down Expand Up @@ -511,7 +511,7 @@ impl_op! {
arr[14] as u8 as u16 as i16,
arr[15] as u8 as u16 as i16,
];
(core::mem::transmute(a), core::mem::transmute(b))
(core::mem::transmute::<[i16; 8], __m128i>(a), core::mem::transmute::<[i16; 8], __m128i>(b))
}
for Scalar(val: i8) -> (i16, i16) {
(val as u8 as u16 as i16, 0)
Expand Down
24 changes: 12 additions & 12 deletions src/tests/lib/arbitrary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ const IMPORTANT_F32: [f32; 10] = [
-0.5,
1.5,
-1.5,
std::f32::MAX,
std::f32::MIN,
f32::MAX,
f32::MIN,
f32::NAN,
];

Expand All @@ -34,15 +34,15 @@ const IMPORTANT_F64: [f64; 10] = [
-0.5,
1.5,
-1.5,
std::f64::MAX,
std::f64::MIN,
f64::MAX,
f64::MIN,
f64::NAN,
];

const IMPORTANT_I8: [i8; 7] = [0, 1, -1, 2, -2, std::i8::MAX, std::i8::MIN];
const IMPORTANT_I16: [i16; 7] = [0, 1, -1, 2, -2, std::i16::MAX, std::i16::MIN];
const IMPORTANT_I32: [i32; 7] = [0, 1, -1, 2, -2, std::i32::MAX, std::i32::MIN];
const IMPORTANT_I64: [i64; 7] = [0, 1, -1, 2, -2, std::i64::MAX, std::i64::MIN];
const IMPORTANT_I8: [i8; 7] = [0, 1, -1, 2, -2, i8::MAX, i8::MIN];
const IMPORTANT_I16: [i16; 7] = [0, 1, -1, 2, -2, i16::MAX, i16::MIN];
const IMPORTANT_I32: [i32; 7] = [0, 1, -1, 2, -2, i32::MAX, i32::MIN];
const IMPORTANT_I64: [i64; 7] = [0, 1, -1, 2, -2, i64::MAX, i64::MIN];

fn iter_arbitrary_f32(interval: usize) -> impl Iterator<Item = f32> {
assert!(interval > IMPORTANT_F32.len());
Expand Down Expand Up @@ -101,19 +101,19 @@ fn iter_arbitrary_ints<T: SampleUniform + Clone>(
}

fn iter_arbitrary_i8(interval: usize) -> impl Iterator<Item = i8> {
iter_arbitrary_ints(interval, &IMPORTANT_I8, std::i8::MIN..=std::i8::MAX)
iter_arbitrary_ints(interval, &IMPORTANT_I8, i8::MIN..=i8::MAX)
}

fn iter_arbitrary_i16(interval: usize) -> impl Iterator<Item = i16> {
iter_arbitrary_ints(interval, &IMPORTANT_I16, std::i16::MIN..=std::i16::MAX)
iter_arbitrary_ints(interval, &IMPORTANT_I16, i16::MIN..=i16::MAX)
}

fn iter_arbitrary_i32(interval: usize) -> impl Iterator<Item = i32> {
iter_arbitrary_ints(interval, &IMPORTANT_I32, std::i32::MIN..=std::i32::MAX)
iter_arbitrary_ints(interval, &IMPORTANT_I32, i32::MIN..=i32::MAX)
}

fn iter_arbitrary_i64(interval: usize) -> impl Iterator<Item = i64> {
iter_arbitrary_ints(interval, &IMPORTANT_I64, std::i64::MIN..=std::i64::MAX)
iter_arbitrary_ints(interval, &IMPORTANT_I64, i64::MIN..=i64::MAX)
}

fn iter_arbitrary_blendv_i8() -> impl Iterator<Item = i8> {
Expand Down
2 changes: 2 additions & 0 deletions src/tests/lib/fn_tuple.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(dead_code)]
#![allow(non_snake_case)]
//! Some traits for using tuples as function arguments. Mostly copied from warp, with minor modifications.
//! https://github.com/seanmonstar/warp/blob/4e9c4fd6ce238197fd1088061bbc07fa2852cb0f/src/generic.rs
//!
Expand Down
2 changes: 0 additions & 2 deletions src/tests/lib/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ mod arbitrary;
pub use arbitrary::*;

mod fn_tuple;
pub use fn_tuple::*;

mod tester;
pub use tester::*;
Expand All @@ -13,4 +12,3 @@ mod numbers;
pub use numbers::*;

mod constify;
pub use constify::*;

0 comments on commit a1a33e8

Please sign in to comment.