Skip to content

Commit 75380ea

Browse files
authored
Clarify validity regarding initialization
1 parent 8d3a47e commit 75380ea

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

library/core/src/mem/maybe_uninit.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,13 @@ use crate::{fmt, intrinsics, ptr, slice};
278278
/// may not be preserved in `MaybeUninit<U>`, and so `transmute(u)` may produce a `T` with
279279
/// uninitialized bytes in these positions. This is an active area of discussion, and this code
280280
/// may become sound in the future.
281+
282+
/// If byte offsets exists at which `T`'s representation does not permit uninitialized bytes but
283+
/// `U`'s representation does (e.g. due to padding), then the bytes in `T` at these offsets may
284+
/// not be preserved in `u`, and so `transmute(u)` may produce a `T` with uninitialized bytes at
285+
/// these offsets. This is an active area of discussion, and this code may become sound in the future.
281286
///
282-
/// Note that, so long as every byte position which is initialized in `T` is also initialized
283-
/// in `U`, then the preceding `identity` example *is* sound.
287+
/// Note that, so long as no such byte offsets exist, then the preceding `identity` example *is* sound.
284288
///
285289
/// # Provenance
286290
///

0 commit comments

Comments
 (0)