Skip to content

Commit 21f6fa2

Browse files
authored
Document provenance more clearly
1 parent 007b2bf commit 21f6fa2

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

library/core/src/mem/maybe_uninit.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -277,17 +277,13 @@ use crate::{fmt, intrinsics, ptr, slice};
277277
/// may not be preserved in `MaybeUninit<U>`. Interpreting the representation of `u` at type `T` again (i.e., `transmute(u)` above) may thus
278278
/// be undefined behavior or yield a value different from `t` due to those bytes being lost. This is an active area of discussion, and this code
279279
/// may become sound in the future.
280-
281-
/// If byte offsets exists at which `T`'s representation does not permit uninitialized bytes but
282-
/// `U`'s representation does (e.g. due to padding), then the bytes in `T` at these offsets may
283-
/// not be preserved in `u`, and so `transmute(u)` may produce a `T` with uninitialized bytes at
284-
/// these offsets. This is an active area of discussion, and this code may become sound in the future.
285280
///
286281
/// Note that, so long as no such byte offsets exist, then the preceding `identity` example *is* sound.
287282
///
288-
/// # Provenance
283+
/// ## Provenance
289284
///
290-
/// `MaybeUninit` values may contain [pointer provenance][provenance]. Concretely, for any
285+
/// As stated above, `MaybeUninit` permits any byte value at any byte offset. This includes values
286+
/// which contain [pointer provenance][provenance]. A possibly useful implication is that, for any
291287
/// value, `p: P`, which contains provenance, transmuting `p` to `MaybeUninit<[u8; size_of::<P>]>`
292288
/// and then back to `P` will produce a value identical to `p`, including provenance.
293289
///

0 commit comments

Comments
 (0)