Skip to content

Commit

Permalink
Unrolled build for rust-lang#121935
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#121935 - RalfJung:ptr-without-prov, r=scottmcm

library/ptr: mention that ptr::without_provenance is equivalent to deriving from the null ptr

This might help clarify why you can't do memory accesses with it.
  • Loading branch information
rust-timer authored Mar 4, 2024
2 parents 70aa0b8 + d579caf commit cfb3891
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions library/core/src/ptr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,8 @@ pub const fn null_mut<T: ?Sized + Thin>() -> *mut T {

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

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

0 comments on commit cfb3891

Please sign in to comment.