26
26
//! some memory happens to exist at that address and gets deallocated. This corresponds to writing
27
27
//! your own allocator: allocating zero-sized objects is not very hard. The canonical way to
28
28
//! obtain a pointer that is valid for zero-sized accesses is [`NonNull::dangling`].
29
+ //FIXME: mention `ptr::invalid` above, once it is stable.
29
30
//! * All accesses performed by functions in this module are *non-atomic* in the sense
30
31
//! of [atomic operations] used to synchronize between threads. This means it is
31
32
//! undefined behavior to perform two concurrent accesses to the same location from different
@@ -557,16 +558,16 @@ pub const fn null_mut<T>() -> *mut T {
557
558
558
559
/// Creates an invalid pointer with the given address.
559
560
///
560
- /// This is *currently* equivalent to `addr as *const T` but it expresses the intended semantic
561
- /// more clearly, and may become important under future memory models .
561
+ /// This is different from `addr as *const T`, which creates a pointer that picks up a previously
562
+ /// exposed provenance. See [`from_exposed_addr`] for more details on that operation .
562
563
///
563
564
/// The module's top-level documentation discusses the precise meaning of an "invalid"
564
565
/// pointer but essentially this expresses that the pointer is not associated
565
566
/// with any actual allocation and is little more than a usize address in disguise.
566
567
///
567
568
/// This pointer will have no provenance associated with it and is therefore
568
569
/// UB to read/write/offset. This mostly exists to facilitate things
569
- /// like ptr::null and NonNull::dangling which make invalid pointers.
570
+ /// like ` ptr::null` and ` NonNull::dangling` which make invalid pointers.
570
571
///
571
572
/// (Standard "Zero-Sized-Types get to cheat and lie" caveats apply, although it
572
573
/// may be desirable to give them their own API just to make that 100% clear.)
@@ -588,16 +589,16 @@ pub const fn invalid<T>(addr: usize) -> *const T {
588
589
589
590
/// Creates an invalid mutable pointer with the given address.
590
591
///
591
- /// This is *currently* equivalent to `addr as *mut T` but it expresses the intended semantic
592
- /// more clearly, and may become important under future memory models .
592
+ /// This is different from `addr as *mut T`, which creates a pointer that picks up a previously
593
+ /// exposed provenance. See [`from_exposed_addr_mut`] for more details on that operation .
593
594
///
594
595
/// The module's top-level documentation discusses the precise meaning of an "invalid"
595
596
/// pointer but essentially this expresses that the pointer is not associated
596
597
/// with any actual allocation and is little more than a usize address in disguise.
597
598
///
598
599
/// This pointer will have no provenance associated with it and is therefore
599
600
/// UB to read/write/offset. This mostly exists to facilitate things
600
- /// like ptr::null and NonNull::dangling which make invalid pointers.
601
+ /// like ` ptr::null` and ` NonNull::dangling` which make invalid pointers.
601
602
///
602
603
/// (Standard "Zero-Sized-Types get to cheat and lie" caveats apply, although it
603
604
/// may be desirable to give them their own API just to make that 100% clear.)
0 commit comments