From 279c39acf6c4fd2b7273a0675a49ecfaf4326215 Mon Sep 17 00:00:00 2001 From: Joshua Liebow-Feeser Date: Fri, 6 Mar 2026 12:14:15 -0500 Subject: [PATCH 1/4] `Sized` types are not larger than `isize::MAX` --- src/type-layout.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/type-layout.md b/src/type-layout.md index 28daeef450..af354bbe2e 100644 --- a/src/type-layout.md +++ b/src/type-layout.md @@ -21,7 +21,7 @@ r[layout.properties.size] The *size* of a value is the offset in bytes between successive elements in an array with that item type including alignment padding. The size of a value is always a multiple of its alignment. Note that some types are zero-sized; 0 is considered a multiple of any alignment (for example, on some platforms, the type `[u16; 0]` has size 0 and alignment 2). The size of a value can be checked with the [`size_of_val`] function. r[layout.properties.sized] -Types where all values have the same size and alignment, and both are known at compile time, implement the [`Sized`] trait and can be checked with the [`size_of`] and [`align_of`] functions. Types that are not [`Sized`] are known as [dynamically sized types]. Since all values of a `Sized` type share the same size and alignment, we refer to those shared values as the size of the type and the alignment of the type respectively. +Types where all values have the same size and alignment, and both are known at compile time, implement the [`Sized`] trait and can be checked with the [`size_of`] and [`align_of`] functions. Types that are not [`Sized`] are known as [dynamically sized types]. Since all values of a `Sized` type share the same size and alignment, we refer to those shared values as the size of the type and the alignment of the type respectively. The size of a `Sized` type is guaranteed not to exceed `isize::MAX`. r[layout.primitive] ## Primitive data layout From 3a8400e6be5db6ee37b339f117d018e5028e9d8e Mon Sep 17 00:00:00 2001 From: Joshua Liebow-Feeser Date: Fri, 6 Mar 2026 12:30:35 -0500 Subject: [PATCH 2/4] Constrain value size to `isize::MAX` --- src/type-layout.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/type-layout.md b/src/type-layout.md index af354bbe2e..75f3a5a429 100644 --- a/src/type-layout.md +++ b/src/type-layout.md @@ -18,10 +18,10 @@ r[layout.properties.align] The *alignment* of a value specifies what addresses are valid to store the value at. A value of alignment `n` must only be stored at an address that is a multiple of n. For example, a value with an alignment of 2 must be stored at an even address, while a value with an alignment of 1 can be stored at any address. Alignment is measured in bytes, and must be at least 1, and always a power of 2. The alignment of a value can be checked with the [`align_of_val`] function. r[layout.properties.size] -The *size* of a value is the offset in bytes between successive elements in an array with that item type including alignment padding. The size of a value is always a multiple of its alignment. Note that some types are zero-sized; 0 is considered a multiple of any alignment (for example, on some platforms, the type `[u16; 0]` has size 0 and alignment 2). The size of a value can be checked with the [`size_of_val`] function. +The *size* of a value is the offset in bytes between successive elements in an array with that item type including alignment padding. The size of a value is always a multiple of its alignment, and never exceeds `isize::MAX`. Note that some types are zero-sized; 0 is considered a multiple of any alignment (for example, on some platforms, the type `[u16; 0]` has size 0 and alignment 2). The size of a value can be checked with the [`size_of_val`] function. r[layout.properties.sized] -Types where all values have the same size and alignment, and both are known at compile time, implement the [`Sized`] trait and can be checked with the [`size_of`] and [`align_of`] functions. Types that are not [`Sized`] are known as [dynamically sized types]. Since all values of a `Sized` type share the same size and alignment, we refer to those shared values as the size of the type and the alignment of the type respectively. The size of a `Sized` type is guaranteed not to exceed `isize::MAX`. +Types where all values have the same size and alignment, and both are known at compile time, implement the [`Sized`] trait and can be checked with the [`size_of`] and [`align_of`] functions. Types that are not [`Sized`] are known as [dynamically sized types]. Since all values of a `Sized` type share the same size and alignment, we refer to those shared values as the size of the type and the alignment of the type respectively. The size of a `Sized` type is guaranteed not to exceed `isize::MAX`. (Note that this guarantee is distinct from the guarantee that the size of a *value* does not exceed `isize::MAX` – this guarantee applies *even if a `Sized` type is never instantiated*.) r[layout.primitive] ## Primitive data layout From 4e5584d9605e94a69e51a8fff573d31f43ea87e8 Mon Sep 17 00:00:00 2001 From: Joshua Liebow-Feeser Date: Fri, 6 Mar 2026 12:39:11 -0500 Subject: [PATCH 3/4] Fix formatting issue in type-layout.md --- src/type-layout.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/type-layout.md b/src/type-layout.md index 75f3a5a429..79147424bf 100644 --- a/src/type-layout.md +++ b/src/type-layout.md @@ -21,7 +21,7 @@ r[layout.properties.size] The *size* of a value is the offset in bytes between successive elements in an array with that item type including alignment padding. The size of a value is always a multiple of its alignment, and never exceeds `isize::MAX`. Note that some types are zero-sized; 0 is considered a multiple of any alignment (for example, on some platforms, the type `[u16; 0]` has size 0 and alignment 2). The size of a value can be checked with the [`size_of_val`] function. r[layout.properties.sized] -Types where all values have the same size and alignment, and both are known at compile time, implement the [`Sized`] trait and can be checked with the [`size_of`] and [`align_of`] functions. Types that are not [`Sized`] are known as [dynamically sized types]. Since all values of a `Sized` type share the same size and alignment, we refer to those shared values as the size of the type and the alignment of the type respectively. The size of a `Sized` type is guaranteed not to exceed `isize::MAX`. (Note that this guarantee is distinct from the guarantee that the size of a *value* does not exceed `isize::MAX` – this guarantee applies *even if a `Sized` type is never instantiated*.) +Types where all values have the same size and alignment, and both are known at compile time, implement the [`Sized`] trait and can be checked with the [`size_of`] and [`align_of`] functions. Types that are not [`Sized`] are known as [dynamically sized types]. Since all values of a `Sized` type share the same size and alignment, we refer to those shared values as the size of the type and the alignment of the type respectively. The size of a `Sized` type is guaranteed not to exceed `isize::MAX`. (Note that this guarantee is distinct from the guarantee that the size of a *value* does not exceed `isize::MAX` -- this guarantee applies *even if a `Sized` type is never instantiated*.) r[layout.primitive] ## Primitive data layout From 5fca02c21e0c34a5f66fb2627c4e9cb45a525980 Mon Sep 17 00:00:00 2001 From: Joshua Liebow-Feeser Date: Fri, 6 Mar 2026 12:49:12 -0500 Subject: [PATCH 4/4] Update src/type-layout.md Co-authored-by: Jacob Lifshay --- src/type-layout.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/type-layout.md b/src/type-layout.md index 79147424bf..38ea4ab1ba 100644 --- a/src/type-layout.md +++ b/src/type-layout.md @@ -21,7 +21,7 @@ r[layout.properties.size] The *size* of a value is the offset in bytes between successive elements in an array with that item type including alignment padding. The size of a value is always a multiple of its alignment, and never exceeds `isize::MAX`. Note that some types are zero-sized; 0 is considered a multiple of any alignment (for example, on some platforms, the type `[u16; 0]` has size 0 and alignment 2). The size of a value can be checked with the [`size_of_val`] function. r[layout.properties.sized] -Types where all values have the same size and alignment, and both are known at compile time, implement the [`Sized`] trait and can be checked with the [`size_of`] and [`align_of`] functions. Types that are not [`Sized`] are known as [dynamically sized types]. Since all values of a `Sized` type share the same size and alignment, we refer to those shared values as the size of the type and the alignment of the type respectively. The size of a `Sized` type is guaranteed not to exceed `isize::MAX`. (Note that this guarantee is distinct from the guarantee that the size of a *value* does not exceed `isize::MAX` -- this guarantee applies *even if a `Sized` type is never instantiated*.) +Types where all values have the same size and alignment, and both are known at compile time, implement the [`Sized`] trait and can be checked with the [`size_of`] and [`align_of`] functions. Types that are not [`Sized`] are known as [dynamically sized types]. Since all values of a `Sized` type share the same size and alignment, we refer to those shared values as the size of the type and the alignment of the type respectively. The size of a `Sized` type is guaranteed not to exceed `isize::MAX`. (Note that this guarantee is distinct from the guarantee that the size of a *value* does not exceed `isize::MAX` -- this guarantee applies *even if a `Sized` type is never instantiated*.) r[layout.primitive] ## Primitive data layout