From f13a05ab71afdb3b6389e8ba1b8204e475fc66fb Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 7 Nov 2023 08:06:55 +0100 Subject: [PATCH] avoid using unstable ptr::invalid_mut --- src/raw/mod.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/raw/mod.rs b/src/raw/mod.rs index 25c5d1c4d..71c82f204 100644 --- a/src/raw/mod.rs +++ b/src/raw/mod.rs @@ -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(addr: usize) -> *mut T { - addr as *mut T + unsafe { core::mem::transmute(addr) } } #[inline]