Skip to content

Commit

Permalink
Replace transmute with pointer cast
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Aug 17, 2024
1 parent fcc8b8f commit a716d18
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ use core::fmt::{self, Debug};
#[cfg(not(no_const_type_id))]
use core::hash::{Hash, Hasher};
use core::marker::PhantomData;
use core::mem;

#[cfg(not(no_const_type_id))]
#[derive(Copy, Clone)]
Expand Down Expand Up @@ -217,6 +216,6 @@ where

let phantom_data = PhantomData::<T>;
NonStaticAny::get_type_id(unsafe {
mem::transmute::<&dyn NonStaticAny, &(dyn NonStaticAny + 'static)>(&phantom_data)
&*(&phantom_data as *const dyn NonStaticAny as *const (dyn NonStaticAny + 'static))
})
}

0 comments on commit a716d18

Please sign in to comment.