From 2c6b3819aed58ac41ba3fa7905288f3af24e0a9d 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 6466741893..6f16fa2c04 100644 --- a/src/type-layout.md +++ b/src/type-layout.md @@ -49,7 +49,7 @@ r[layout.primitive.size-align] `usize` and `isize` have the same size and alignment. 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 2e51321b2ba05f51aeca78194d84d7f8400c0c99 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 6f16fa2c04..469c25e783 100644 --- a/src/type-layout.md +++ b/src/type-layout.md @@ -49,7 +49,7 @@ r[layout.primitive.size-align] `usize` and `isize` have the same size and alignment. 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 aefd8d24b3b9702f60ea93bf7713941e8e9a3cbf 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 469c25e783..de45ba4efa 100644 --- a/src/type-layout.md +++ b/src/type-layout.md @@ -48,8 +48,11 @@ r[layout.primitive.size-minimum] r[layout.primitive.size-align] `usize` and `isize` have the same size and alignment. -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 82c2212a27a916797f9ef14353d92ee985ffb4d7 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 de45ba4efa..6d25fbb4f1 100644 --- a/src/type-layout.md +++ b/src/type-layout.md @@ -52,7 +52,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