Skip to content

Commit 53e3519

Browse files
authored
Rollup merge of rust-lang#63295 - RalfJung:align_offset, r=dtolnay
improve align_offset docs Cc @shepmaster
2 parents c668bb7 + 1f01863 commit 53e3519

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/libcore/ptr/mod.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -1606,10 +1606,12 @@ impl<T: ?Sized> *const T {
16061606
/// `align`.
16071607
///
16081608
/// If it is not possible to align the pointer, the implementation returns
1609-
/// `usize::max_value()`.
1609+
/// `usize::max_value()`. It is permissible for the implementation to *always*
1610+
/// return `usize::max_value()`. Only your algorithm's performance can depend
1611+
/// on getting a usable offset here, not its correctness.
16101612
///
16111613
/// The offset is expressed in number of `T` elements, and not bytes. The value returned can be
1612-
/// used with the `add` method.
1614+
/// used with the `wrapping_add` method.
16131615
///
16141616
/// There are no guarantees whatsoever that offsetting the pointer will not overflow or go
16151617
/// beyond the allocation that the pointer points into. It is up to the caller to ensure that
@@ -2407,10 +2409,12 @@ impl<T: ?Sized> *mut T {
24072409
/// `align`.
24082410
///
24092411
/// If it is not possible to align the pointer, the implementation returns
2410-
/// `usize::max_value()`.
2412+
/// `usize::max_value()`. It is permissible for the implementation to *always*
2413+
/// return `usize::max_value()`. Only your algorithm's performance can depend
2414+
/// on getting a usable offset here, not its correctness.
24112415
///
24122416
/// The offset is expressed in number of `T` elements, and not bytes. The value returned can be
2413-
/// used with the `add` method.
2417+
/// used with the `wrapping_add` method.
24142418
///
24152419
/// There are no guarantees whatsoever that offsetting the pointer will not overflow or go
24162420
/// beyond the allocation that the pointer points into. It is up to the caller to ensure that

0 commit comments

Comments
 (0)