Skip to content

Commit

Permalink
Don't transmute function pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
Amanieu committed Jun 19, 2024
1 parent e2b6b85 commit 7807774
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/raw/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1235,7 +1235,7 @@ impl<T, A: Allocator> RawTable<T, A> {
fallibility,
Self::TABLE_LAYOUT,
if T::NEEDS_DROP {
Some(mem::transmute(ptr::drop_in_place::<T> as unsafe fn(*mut T)))
Some(|ptr| ptr::drop_in_place(ptr as *mut T))
} else {
None
},
Expand Down Expand Up @@ -2911,7 +2911,7 @@ impl RawTableInner {
hasher: &dyn Fn(&mut Self, usize) -> u64,
fallibility: Fallibility,
layout: TableLayout,
drop: Option<fn(*mut u8)>,
drop: Option<unsafe fn(*mut u8)>,
) -> Result<(), TryReserveError>
where
A: Allocator,
Expand Down Expand Up @@ -3145,7 +3145,7 @@ impl RawTableInner {
&mut self,
hasher: &dyn Fn(&mut Self, usize) -> u64,
size_of: usize,
drop: Option<fn(*mut u8)>,
drop: Option<unsafe fn(*mut u8)>,
) {
// If the hash function panics then properly clean up any elements
// that we haven't rehashed yet. We unfortunately can't preserve the
Expand Down Expand Up @@ -4577,7 +4577,7 @@ mod test_map {
&|table, index| hasher(table.bucket::<T>(index).as_ref()),
mem::size_of::<T>(),
if mem::needs_drop::<T>() {
Some(mem::transmute(ptr::drop_in_place::<T> as unsafe fn(*mut T)))
Some(|ptr| ptr::drop_in_place(ptr as *mut T))
} else {
None
},
Expand Down

0 comments on commit 7807774

Please sign in to comment.