Skip to content

Commit 2e138e9

Browse files
committed
Auto merge of #481 - RalfJung:ptr-invalid, r=Amanieu
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.
2 parents 778e235 + f13a05a commit 2e138e9

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/raw/mod.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,12 @@ use core::convert::identity as unlikely;
5757
#[cfg(feature = "nightly")]
5858
use core::intrinsics::{likely, unlikely};
5959

60-
// Use strict provenance functions if available.
61-
#[cfg(feature = "nightly")]
62-
use core::ptr::invalid_mut;
63-
// Implement it with a cast otherwise.
64-
#[cfg(not(feature = "nightly"))]
60+
// FIXME: use strict provenance functions once they are stable.
61+
// Implement it with a transmute for now.
6562
#[inline(always)]
63+
#[allow(clippy::useless_transmute)] // clippy is wrong, cast and transmute are different here
6664
fn invalid_mut<T>(addr: usize) -> *mut T {
67-
addr as *mut T
65+
unsafe { core::mem::transmute(addr) }
6866
}
6967

7068
#[inline]

0 commit comments

Comments
 (0)