Rollup merge of #123048 - RalfJung:layout, r=dtolnay

alloc::Layout: explicitly document size invariant on the type level

https://github.com/rust-lang/rust/pull/95295 added this to the constructor, but it seems worth documenting the type invariant at the type level.
This commit is contained in:
León Orell Valerian Liehr 2024-04-23 17:25:16 +02:00 committed by GitHub
commit 2d7d480054
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -25,7 +25,9 @@ const fn size_align<T>() -> (usize, usize) {
/// An instance of `Layout` describes a particular layout of memory.
/// You build a `Layout` up as an input to give to an allocator.
///
/// All layouts have an associated size and a power-of-two alignment.
/// All layouts have an associated size and a power-of-two alignment. The size, when rounded up to
/// the nearest multiple of `align`, does not overflow isize (i.e., the rounded value will always be
/// less than or equal to `isize::MAX`).
///
/// (Note that layouts are *not* required to have non-zero size,
/// even though `GlobalAlloc` requires that all memory requests