@@ -596,12 +596,7 @@ pub const fn null_mut<T: ?Sized + Thin>() -> *mut T {
596596#[ stable( feature = "strict_provenance" , since = "1.84.0" ) ]
597597#[ rustc_const_stable( feature = "strict_provenance" , since = "1.84.0" ) ]
598598pub const fn without_provenance < T > ( addr : usize ) -> * const T {
599- // An int-to-pointer transmute currently has exactly the intended semantics: it creates a
600- // pointer without provenance. Note that this is *not* a stable guarantee about transmute
601- // semantics, it relies on sysroot crates having special status.
602- // SAFETY: every valid integer is also a valid pointer (as long as you don't dereference that
603- // pointer).
604- unsafe { mem:: transmute ( addr) }
599+ without_provenance_mut ( addr)
605600}
606601
607602/// Creates a new pointer that is dangling, but non-null and well-aligned.
@@ -618,7 +613,7 @@ pub const fn without_provenance<T>(addr: usize) -> *const T {
618613#[ stable( feature = "strict_provenance" , since = "1.84.0" ) ]
619614#[ rustc_const_stable( feature = "strict_provenance" , since = "1.84.0" ) ]
620615pub const fn dangling < T > ( ) -> * const T {
621- without_provenance ( mem :: align_of :: < T > ( ) )
616+ dangling_mut ( )
622617}
623618
624619/// Creates a pointer with the given address and no [provenance][crate::ptr#provenance].
@@ -661,7 +656,7 @@ pub const fn without_provenance_mut<T>(addr: usize) -> *mut T {
661656#[ stable( feature = "strict_provenance" , since = "1.84.0" ) ]
662657#[ rustc_const_stable( feature = "strict_provenance" , since = "1.84.0" ) ]
663658pub const fn dangling_mut < T > ( ) -> * mut T {
664- without_provenance_mut ( mem :: align_of :: < T > ( ) )
659+ NonNull :: dangling ( ) . as_ptr ( )
665660}
666661
667662/// Converts an address back to a pointer, picking up some previously 'exposed'
0 commit comments