@@ -596,12 +596,7 @@ pub const fn null_mut<T: ?Sized + Thin>() -> *mut T {
596
596
#[ stable( feature = "strict_provenance" , since = "1.84.0" ) ]
597
597
#[ rustc_const_stable( feature = "strict_provenance" , since = "1.84.0" ) ]
598
598
pub 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)
605
600
}
606
601
607
602
/// 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 {
618
613
#[ stable( feature = "strict_provenance" , since = "1.84.0" ) ]
619
614
#[ rustc_const_stable( feature = "strict_provenance" , since = "1.84.0" ) ]
620
615
pub const fn dangling < T > ( ) -> * const T {
621
- without_provenance ( mem :: align_of :: < T > ( ) )
616
+ dangling_mut ( )
622
617
}
623
618
624
619
/// 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 {
661
656
#[ stable( feature = "strict_provenance" , since = "1.84.0" ) ]
662
657
#[ rustc_const_stable( feature = "strict_provenance" , since = "1.84.0" ) ]
663
658
pub const fn dangling_mut < T > ( ) -> * mut T {
664
- without_provenance_mut ( mem :: align_of :: < T > ( ) )
659
+ NonNull :: dangling ( ) . as_ptr ( )
665
660
}
666
661
667
662
/// Converts an address back to a pointer, picking up some previously 'exposed'
0 commit comments