From 7231a844fddd775d79ade4bcd3c580d27618ecee Mon Sep 17 00:00:00 2001 From: Arduano Date: Thu, 5 Dec 2024 20:28:38 +1100 Subject: [PATCH] Further clippy fixes Fixed up some new warnings created by clippy --- benches/numparse.rs | 2 +- examples/string_parse_sum.rs | 2 +- src/base/iters.rs | 2 +- src/lib.rs | 6 +----- src/libm_ext/mod.rs | 1 + src/ops/f64.rs | 8 ++++---- src/ops/i16.rs | 4 ++-- src/ops/i32.rs | 15 +++++++++------ src/ops/i64.rs | 22 +++++++++++----------- src/ops/i8.rs | 16 ++++++++-------- src/tests/lib/arbitrary.rs | 24 ++++++++++++------------ src/tests/lib/fn_tuple.rs | 2 ++ src/tests/lib/mod.rs | 2 -- 13 files changed, 53 insertions(+), 53 deletions(-) diff --git a/benches/numparse.rs b/benches/numparse.rs index fbb48f7..f2aa676 100644 --- a/benches/numparse.rs +++ b/benches/numparse.rs @@ -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, } diff --git a/examples/string_parse_sum.rs b/examples/string_parse_sum.rs index cb19b21..ccb4c0a 100644 --- a/examples/string_parse_sum.rs +++ b/examples/string_parse_sum.rs @@ -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, } } diff --git a/src/base/iters.rs b/src/base/iters.rs index 2cc6c9c..e0902b5 100644 --- a/src/base/iters.rs +++ b/src/base/iters.rs @@ -25,7 +25,7 @@ pub struct SimdArrayIterator<'a, S: SimdBaseIo> { index: usize, } -impl<'a, S: SimdBaseIo> Iterator for SimdArrayIterator<'a, S> { +impl Iterator for SimdArrayIterator<'_, S> { type Item = S::Scalar; #[inline(always)] diff --git a/src/lib.rs b/src/lib.rs index 2078dbe..81e47d7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -147,15 +147,11 @@ //! //! * `distance` 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] diff --git a/src/libm_ext/mod.rs b/src/libm_ext/mod.rs index cecece7..952f6a8 100644 --- a/src/libm_ext/mod.rs +++ b/src/libm_ext/mod.rs @@ -1,3 +1,4 @@ +#![allow(dead_code)] #[cfg(feature = "no_std")] mod no_std; diff --git a/src/ops/f64.rs b/src/ops/f64.rs index 0ed63d7..05ebb04 100644 --- a/src/ops/f64.rs +++ b/src/ops/f64.rs @@ -612,7 +612,7 @@ impl_op! { impl_op! { fn cast_i64 { 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, @@ -622,7 +622,7 @@ 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, @@ -630,7 +630,7 @@ impl_op! { 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, @@ -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::(a); let ceil = [ nums_arr[0].m_round() as i64, nums_arr[1].m_round() as i64, diff --git a/src/ops/i16.rs b/src/ops/i16.rs index a94433f..e51edef 100644 --- a/src/ops/i16.rs +++ b/src/ops/i16.rs @@ -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) @@ -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) diff --git a/src/ops/i32.rs b/src/ops/i32.rs index e823462..2e5b087 100644 --- a/src/ops/i32.rs +++ b/src/ops/i32.rs @@ -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]), @@ -450,10 +450,13 @@ impl_op! { Ops::::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) @@ -477,10 +480,10 @@ impl_op! { Ops::::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) diff --git a/src/ops/i64.rs b/src/ops/i64.rs index 84dc11f..532f62e 100644 --- a/src/ops/i64.rs +++ b/src/ops/i64.rs @@ -43,8 +43,8 @@ impl_op! { impl_op! { fn mul { 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]), @@ -54,8 +54,8 @@ 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]), @@ -63,8 +63,8 @@ impl_op! { 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]), @@ -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::(a); + let b_arr = core::mem::transmute::(b); let c_arr = [ a_arr[0].wrapping_mul(b_arr[0]), a_arr[1].wrapping_mul(b_arr[1]), @@ -430,7 +430,7 @@ impl_imm8_op! { impl_op! { fn cast_f64 { 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, @@ -440,7 +440,7 @@ 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, @@ -448,7 +448,7 @@ impl_op! { 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, diff --git a/src/ops/i8.rs b/src/ops/i8.rs index 27bf42d..a50d5a0 100644 --- a/src/ops/i8.rs +++ b/src/ops/i8.rs @@ -43,24 +43,24 @@ impl_op! { impl_op! { fn mul { 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]); } @@ -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) @@ -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) diff --git a/src/tests/lib/arbitrary.rs b/src/tests/lib/arbitrary.rs index 7eb50eb..21121f1 100644 --- a/src/tests/lib/arbitrary.rs +++ b/src/tests/lib/arbitrary.rs @@ -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, ]; @@ -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 { assert!(interval > IMPORTANT_F32.len()); @@ -101,19 +101,19 @@ fn iter_arbitrary_ints( } fn iter_arbitrary_i8(interval: usize) -> impl Iterator { - 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 { - 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 { - 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 { - 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 { diff --git a/src/tests/lib/fn_tuple.rs b/src/tests/lib/fn_tuple.rs index fb99586..5ce49ab 100644 --- a/src/tests/lib/fn_tuple.rs +++ b/src/tests/lib/fn_tuple.rs @@ -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 //! diff --git a/src/tests/lib/mod.rs b/src/tests/lib/mod.rs index 46216f3..723ec11 100644 --- a/src/tests/lib/mod.rs +++ b/src/tests/lib/mod.rs @@ -4,7 +4,6 @@ mod arbitrary; pub use arbitrary::*; mod fn_tuple; -pub use fn_tuple::*; mod tester; pub use tester::*; @@ -13,4 +12,3 @@ mod numbers; pub use numbers::*; mod constify; -pub use constify::*;