Skip to content

Commit d579caf

Browse files
committed
library/ptr: mention that ptr::without_provenance is equivalent to deriving from the null ptr
1 parent 3793e5b commit d579caf

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

library/core/src/ptr/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,8 @@ pub const fn null_mut<T: ?Sized + Thin>() -> *mut T {
574574

575575
/// Creates a pointer with the given address and no provenance.
576576
///
577+
/// This is equivalent to `ptr::null().with_addr(addr)`.
578+
///
577579
/// Without provenance, this pointer is not associated with any actual allocation. Such a
578580
/// no-provenance pointer may be used for zero-sized memory accesses (if suitably aligned), but
579581
/// non-zero-sized memory accesses with a no-provenance pointer are UB. No-provenance pointers are
@@ -616,6 +618,8 @@ pub const fn dangling<T>() -> *const T {
616618

617619
/// Creates a pointer with the given address and no provenance.
618620
///
621+
/// This is equivalent to `ptr::null_mut().with_addr(addr)`.
622+
///
619623
/// Without provenance, this pointer is not associated with any actual allocation. Such a
620624
/// no-provenance pointer may be used for zero-sized memory accesses (if suitably aligned), but
621625
/// non-zero-sized memory accesses with a no-provenance pointer are UB. No-provenance pointers are

0 commit comments

Comments
 (0)