about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgonzalobg <65027571+gonzalobg@users.noreply.github.com>2025-08-27 16:21:07 +0200
committerGonzalo Brito Gadeschi <gonzalob@nvidia.com>2025-08-28 11:07:38 -0700
commitf29327ff6093bc09c445028bd05a172e570e8486 (patch)
tree87c9251c790e3d5ba8b0ca05e709cf3bf216da70
parentb2dd217dd0a099fb87601657ec480bf3e92b30a6 (diff)
downloadrust-f29327ff6093bc09c445028bd05a172e570e8486.tar.gz
rust-f29327ff6093bc09c445028bd05a172e570e8486.zip
Clarify that align_offset overaligns
The current documentation is not clear whether adding `a` to a pointer overaligns (align up) or underaligns (align down).

It should say this explicitly.
-rw-r--r--library/core/src/ptr/mod.rs5
1 files changed, 2 insertions, 3 deletions
diff --git a/library/core/src/ptr/mod.rs b/library/core/src/ptr/mod.rs
index 6fc85a83e17..6b94088cb56 100644
--- a/library/core/src/ptr/mod.rs
+++ b/library/core/src/ptr/mod.rs
@@ -2166,10 +2166,9 @@ pub unsafe fn write_volatile<T>(dst: *mut T, src: T) {
     }
 }
 
-/// Align pointer `p`.
+/// Calculate an element-offset that increases a pointer's alignment.
 ///
-/// Calculate offset (in terms of elements of `size_of::<T>()` stride) that has to be applied
-/// to pointer `p` so that pointer `p` would get aligned to `a`.
+/// Calculate an element-offset (not byte-offset) that when added to a given pointer `p`, increases `p`'s alignment to at least the given alignment `a`.
 ///
 /// # Safety
 /// `a` must be a power of two.