From 64b52137c1f6ce117121b059122bf154649d9b7f Mon Sep 17 00:00:00 2001 From: mooman219 Date: Mon, 18 Nov 2024 22:48:46 -0800 Subject: [PATCH] Clippy: transmute used without annotations --- src/font.rs | 2 +- src/platform/float/get_bitmap.rs | 2 +- src/platform/simd_core.rs | 17 ++++++++++++----- src/platform/simd_x86.rs | 10 +++++----- src/table/parse.rs | 12 ++++++------ 5 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/font.rs b/src/font.rs index c147aa20..9808c694 100644 --- a/src/font.rs +++ b/src/font.rs @@ -266,7 +266,7 @@ impl Font { if let Some(mapping) = subtable.glyph_index(codepoint) { if let Some(mapping) = NonZeroU16::new(mapping.0) { indices_to_load.insert(mapping.get()); - char_to_glyph.insert(unsafe { mem::transmute(codepoint) }, mapping); + char_to_glyph.insert(unsafe { mem::transmute::(codepoint) }, mapping); } } }) diff --git a/src/platform/float/get_bitmap.rs b/src/platform/float/get_bitmap.rs index 671e778f..2cf229c1 100644 --- a/src/platform/float/get_bitmap.rs +++ b/src/platform/float/get_bitmap.rs @@ -62,7 +62,7 @@ pub fn get_bitmap(a: &Vec, length: usize) -> Vec { y = _mm_packus_epi16(_mm_packs_epi32(y, nzero), nzero); // Store the first 4 u8s from y in output. - let pointer: &mut i32 = core::mem::transmute(output.get_unchecked_mut(i)); + let pointer: &mut i32 = core::mem::transmute::<&mut u8, &mut i32>(output.get_unchecked_mut(i)); *pointer = core::mem::transmute::<__m128i, [i32; 4]>(y)[0]; // offset = (x[3], x[3], x[3], x[3]) offset = _mm_set1_ps(core::mem::transmute::<__m128, [f32; 4]>(x)[3]); diff --git a/src/platform/simd_core.rs b/src/platform/simd_core.rs index ee6b4622..c7cfceb7 100644 --- a/src/platform/simd_core.rs +++ b/src/platform/simd_core.rs @@ -25,17 +25,24 @@ impl f32x4 { #[inline(always)] pub fn new_u32(x0: u32, x1: u32, x2: u32, x3: u32) -> Self { - unsafe { Self::new(transmute(x0), transmute(x1), transmute(x2), transmute(x3)) } + unsafe { + Self::new( + transmute::(x0), + transmute::(x1), + transmute::(x2), + transmute::(x3), + ) + } } #[inline(always)] pub fn sub_integer(&self, other: f32x4) -> f32x4 { unsafe { Self::new( - transmute(transmute::(self.x0) - transmute::(other.x0)), - transmute(transmute::(self.x1) - transmute::(other.x1)), - transmute(transmute::(self.x2) - transmute::(other.x2)), - transmute(transmute::(self.x3) - transmute::(other.x3)), + transmute::(transmute::(self.x0) - transmute::(other.x0)), + transmute::(transmute::(self.x1) - transmute::(other.x1)), + transmute::(transmute::(self.x2) - transmute::(other.x2)), + transmute::(transmute::(self.x3) - transmute::(other.x3)), ) } } diff --git a/src/platform/simd_x86.rs b/src/platform/simd_x86.rs index 385e5499..c50644dd 100644 --- a/src/platform/simd_x86.rs +++ b/src/platform/simd_x86.rs @@ -21,10 +21,10 @@ impl f32x4 { pub fn new_u32(x0: u32, x1: u32, x2: u32, x3: u32) -> Self { f32x4(unsafe { _mm_set_ps( - core::mem::transmute(x3), - core::mem::transmute(x2), - core::mem::transmute(x1), - core::mem::transmute(x0), + core::mem::transmute::(x3), + core::mem::transmute::(x2), + core::mem::transmute::(x1), + core::mem::transmute::(x0), ) }) } @@ -45,7 +45,7 @@ impl f32x4 { #[inline(always)] pub fn copied(self) -> (f32, f32, f32, f32) { - unsafe { core::mem::transmute(self.0) } + unsafe { core::mem::transmute::<__m128, (f32, f32, f32, f32)>(self.0) } } #[inline(always)] diff --git a/src/table/parse.rs b/src/table/parse.rs index 93377b8e..1e1a75c7 100644 --- a/src/table/parse.rs +++ b/src/table/parse.rs @@ -37,19 +37,19 @@ pub struct StreamSliceI32<'a>(StreamSliceU32<'a>); impl<'a> StreamSliceI8<'a> { #[inline] pub fn get(&self, index: usize) -> Option { - Some(unsafe { core::mem::transmute(self.0.get(index)?) }) + Some(unsafe { core::mem::transmute::(self.0.get(index)?) }) } } impl<'a> StreamSliceI16<'a> { #[inline] pub fn get(&self, index: usize) -> Option { - Some(unsafe { core::mem::transmute(self.0.get(index)?) }) + Some(unsafe { core::mem::transmute::(self.0.get(index)?) }) } } impl<'a> StreamSliceI32<'a> { #[inline] pub fn get(&self, index: usize) -> Option { - Some(unsafe { core::mem::transmute(self.0.get(index)?) }) + Some(unsafe { core::mem::transmute::(self.0.get(index)?) }) } } @@ -164,17 +164,17 @@ impl<'a> Stream<'a> { #[inline] pub fn read_i8(&mut self) -> Option { - Some(unsafe { core::mem::transmute(self.read_u8()?) }) + Some(unsafe { core::mem::transmute::(self.read_u8()?) }) } #[inline] pub fn read_i16(&mut self) -> Option { - Some(unsafe { core::mem::transmute(self.read_u16()?) }) + Some(unsafe { core::mem::transmute::(self.read_u16()?) }) } #[inline] pub fn read_i32(&mut self) -> Option { - Some(unsafe { core::mem::transmute(self.read_u32()?) }) + Some(unsafe { core::mem::transmute::(self.read_u32()?) }) } // FONT