Skip to content

Commit

Permalink
avoid using unstable ptr::invalid_mut
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Nov 7, 2023
1 parent 778e235 commit 39cb3b0
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/raw/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,11 @@ use core::convert::identity as unlikely;
#[cfg(feature = "nightly")]
use core::intrinsics::{likely, unlikely};

// Use strict provenance functions if available.
#[cfg(feature = "nightly")]
use core::ptr::invalid_mut;
// Implement it with a cast otherwise.
#[cfg(not(feature = "nightly"))]
// FIXME: use strict provenance functions once they are stable.
// Implement it with a transmute for now.
#[inline(always)]
fn invalid_mut<T>(addr: usize) -> *mut T {
addr as *mut T
unsafe { core::mem::transmute(addr) }
}

#[inline]
Expand Down

0 comments on commit 39cb3b0

Please sign in to comment.