From 2c7ecae7a18f104239543eba9276a65a0c605ef4 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Thu, 19 Jul 2018 22:18:06 +0700 Subject: [PATCH] core-foundation: Remove 2 transmutes in macros. These transmutes were going from one type of pointer to another, and so can be done as casts instead. Doing so also means that one unsafe block can be removed. This was found via clippy. --- core-foundation/src/lib.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/core-foundation/src/lib.rs b/core-foundation/src/lib.rs index 02ad188..814c240 100644 --- a/core-foundation/src/lib.rs +++ b/core-foundation/src/lib.rs @@ -53,16 +53,13 @@ macro_rules! impl_TCFType { #[inline] unsafe fn wrap_under_get_rule(reference: $ty_ref) -> Self { - use std::mem; - let reference = mem::transmute($crate::base::CFRetain(mem::transmute(reference))); + let reference = $crate::base::CFRetain(reference as *const ::std::os::raw::c_void) as $ty_ref; $crate::base::TCFType::wrap_under_create_rule(reference) } #[inline] fn as_CFTypeRef(&self) -> $crate::base::CFTypeRef { - unsafe { - ::std::mem::transmute(self.as_concrete_TypeRef()) - } + self.as_concrete_TypeRef() as $crate::base::CFTypeRef } #[inline]