Skip to content

Commit 05e6a34

Browse files
authored
Document provenance
1 parent 1494ec7 commit 05e6a34

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

library/core/src/mem/maybe_uninit.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,15 @@ use crate::{fmt, intrinsics, ptr, slice};
281281
///
282282
/// Note that, so long as every byte position which is initialized in `T` is also initialized
283283
/// in `U`, then the preceding `identity` example *is* sound.
284+
///
285+
/// # Provenance
286+
///
287+
/// `MaybeUninit` values may contain [pointer provenance][provenance]. Concretely, for any
288+
/// pointer type, `P`, which contains provenance, transmuting `p: P` to
289+
/// `MaybeUninit<[u8; size_of::<P>]>` and then back to `P` will produce a value identical to
290+
/// `p`, including provenance.
291+
///
292+
/// [provenance]: ../ptr/index.html#provenance
284293
#[stable(feature = "maybe_uninit", since = "1.36.0")]
285294
// Lang item so we can wrap other types in it. This is useful for coroutines.
286295
#[lang = "maybe_uninit"]

0 commit comments

Comments
 (0)