Skip to content

Commit

Permalink
Auto merge of #481 - RalfJung:ptr-invalid, r=Amanieu
Browse files Browse the repository at this point in the history
avoid using unstable ptr::invalid_mut

I want to rename that function in rust-lang/rust#117658, but currently the build fails because hashbrown uses it.
  • Loading branch information
bors committed Nov 15, 2023
2 parents 778e235 + f13a05a commit 2e138e9
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/raw/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,12 @@ 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)]
#[allow(clippy::useless_transmute)] // clippy is wrong, cast and transmute are different here
fn invalid_mut<T>(addr: usize) -> *mut T {
addr as *mut T
unsafe { core::mem::transmute(addr) }
}

#[inline]
Expand Down

0 comments on commit 2e138e9

Please sign in to comment.