From 1fa86069f0c5f74481a03d9679364bd76337df06 Mon Sep 17 00:00:00 2001 From: Joshua Liebow-Feeser Date: Wed, 11 Mar 2026 12:40:08 -0400 Subject: [PATCH 1/4] Guarantee alignment of fixed-width integer primitives --- 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 16dd006e2d..fcafb6e81c 100644 --- a/src/type-layout.md +++ b/src/type-layout.md @@ -46,7 +46,7 @@ r[layout.primitive.size-int] `usize` and `isize` have a size big enough to contain every address on the target platform. For example, on a 32 bit target, this is 4 bytes, and on a 64 bit target, this is 8 bytes. r[layout.primitive.align] -The alignment of primitives is platform-specific. In most cases, their alignment is equal to their size, but it may be less. In particular, `i128` and `u128` are often aligned to 4 or 8 bytes even though their size is 16, and on many 32-bit platforms, `i64`, `u64`, and `f64` are only aligned to 4 bytes, not 8. +The alignment of primitives is platform-specific. In most cases, their alignment is equal to their size, but it may be less. In particular, `i128` and `u128` are often aligned to 4 or 8 bytes even though their size is 16, and on many 32-bit platforms, `i64`, `u64`, and `f64` are only aligned to 4 bytes, not 8. Alignment is guaranteed to be the same for signed and unsigned variants – that is, for a given `N`, `align_of::() == align_of::()`. r[layout.pointer] ## Pointers and references layout From 86463e6e6b4b83ebab89bf88e7796188c1a6f0d3 Mon Sep 17 00:00:00 2001 From: Joshua Liebow-Feeser Date: Wed, 11 Mar 2026 12:42:20 -0400 Subject: [PATCH 2/4] [layout] Fix style --- 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 fcafb6e81c..7d5c9a2cd3 100644 --- a/src/type-layout.md +++ b/src/type-layout.md @@ -46,7 +46,7 @@ r[layout.primitive.size-int] `usize` and `isize` have a size big enough to contain every address on the target platform. For example, on a 32 bit target, this is 4 bytes, and on a 64 bit target, this is 8 bytes. r[layout.primitive.align] -The alignment of primitives is platform-specific. In most cases, their alignment is equal to their size, but it may be less. In particular, `i128` and `u128` are often aligned to 4 or 8 bytes even though their size is 16, and on many 32-bit platforms, `i64`, `u64`, and `f64` are only aligned to 4 bytes, not 8. Alignment is guaranteed to be the same for signed and unsigned variants – that is, for a given `N`, `align_of::() == align_of::()`. +The alignment of primitives is platform-specific. In most cases, their alignment is equal to their size, but it may be less. In particular, `i128` and `u128` are often aligned to 4 or 8 bytes even though their size is 16, and on many 32-bit platforms, `i64`, `u64`, and `f64` are only aligned to 4 bytes, not 8. Alignment is guaranteed to be the same for signed and unsigned variants -- that is, for a given `N`, `align_of::() == align_of::()`. r[layout.pointer] ## Pointers and references layout From 7d4b9ff9fca6a70d00432a771fe357de34a604e9 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Wed, 11 Mar 2026 22:30:48 +0000 Subject: [PATCH 3/4] Separate integer alignment guarantee into new rule The purpose of the existing `layout.primitive.align` rule is to state that the alignment of primitives is platform-specific. Adding a separate alignment guarantee for integers overloads this a bit. Let's instead separate out the rules; we'll rename the existing rule since there are now two rules speaking to alignment. --- src/type-layout.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/type-layout.md b/src/type-layout.md index 7d5c9a2cd3..050204657e 100644 --- a/src/type-layout.md +++ b/src/type-layout.md @@ -45,8 +45,11 @@ The size of most primitives is given in this table. r[layout.primitive.size-int] `usize` and `isize` have a size big enough to contain every address on the target platform. For example, on a 32 bit target, this is 4 bytes, and on a 64 bit target, this is 8 bytes. -r[layout.primitive.align] -The alignment of primitives is platform-specific. In most cases, their alignment is equal to their size, but it may be less. In particular, `i128` and `u128` are often aligned to 4 or 8 bytes even though their size is 16, and on many 32-bit platforms, `i64`, `u64`, and `f64` are only aligned to 4 bytes, not 8. Alignment is guaranteed to be the same for signed and unsigned variants -- that is, for a given `N`, `align_of::() == align_of::()`. +r[layout.primitive.platform-specific-alignment] +The alignment of primitives is platform-specific. In most cases, their alignment is equal to their size, but it may be less. In particular, `i128` and `u128` are often aligned to 4 or 8 bytes even though their size is 16, and on many 32-bit platforms, `i64`, `u64`, and `f64` are only aligned to 4 bytes, not 8. + +r[layout.primitive.integer-alignment] +Alignment is guaranteed to be the same for signed and unsigned variants -- that is, for a given `N`, `align_of::() == align_of::()`. r[layout.pointer] ## Pointers and references layout From 43165ac2c6eaf01c085f0533ff00d26ee1a914fb Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Wed, 11 Mar 2026 22:23:16 +0000 Subject: [PATCH 4/4] Revise wording of integer alignment guarantee Let's make this wording a bit more clear, and let's fix the em dash to use `---` since that's what our renderer expects. --- 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 050204657e..fdf5d76421 100644 --- a/src/type-layout.md +++ b/src/type-layout.md @@ -49,7 +49,7 @@ r[layout.primitive.platform-specific-alignment] The alignment of primitives is platform-specific. In most cases, their alignment is equal to their size, but it may be less. In particular, `i128` and `u128` are often aligned to 4 or 8 bytes even though their size is 16, and on many 32-bit platforms, `i64`, `u64`, and `f64` are only aligned to 4 bytes, not 8. r[layout.primitive.integer-alignment] -Alignment is guaranteed to be the same for signed and unsigned variants -- that is, for a given `N`, `align_of::() == align_of::()`. +Alignment is guaranteed to be the same for fixed-width signed and unsigned integer variants of the same indicated size --- that is, for a given size `N`, `align_of::() == align_of::()`. r[layout.pointer] ## Pointers and references layout