Skip to content

Commit 1082c36

Browse files
committed
fn is_align_to: move some comments closer to the cast they refer to
1 parent 6aff1ca commit 1082c36

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

library/core/src/ptr/const_ptr.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1628,12 +1628,12 @@ impl<T: ?Sized> *const T {
16281628
#[inline]
16291629
const fn const_impl(ptr: *const (), align: usize) -> bool {
16301630
// We can't use the address of `self` in a `const fn`, so we use `align_offset` instead.
1631-
// The cast to `()` is used to
1632-
// 1. deal with fat pointers; and
1633-
// 2. ensure that `align_offset` doesn't actually try to compute an offset.
16341631
ptr.align_offset(align) == 0
16351632
}
16361633

1634+
// The cast to `()` is used to
1635+
// 1. deal with fat pointers; and
1636+
// 2. ensure that `align_offset` (in `const_impl`) doesn't actually try to compute an offset.
16371637
#[cfg_attr(not(bootstrap), allow(unused_unsafe))] // on bootstrap bump, remove unsafe block
16381638
// SAFETY: The two versions are equivalent at runtime.
16391639
unsafe {

library/core/src/ptr/mut_ptr.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1900,12 +1900,12 @@ impl<T: ?Sized> *mut T {
19001900
#[inline]
19011901
const fn const_impl(ptr: *mut (), align: usize) -> bool {
19021902
// We can't use the address of `self` in a `const fn`, so we use `align_offset` instead.
1903-
// The cast to `()` is used to
1904-
// 1. deal with fat pointers; and
1905-
// 2. ensure that `align_offset` doesn't actually try to compute an offset.
19061903
ptr.align_offset(align) == 0
19071904
}
19081905

1906+
// The cast to `()` is used to
1907+
// 1. deal with fat pointers; and
1908+
// 2. ensure that `align_offset` (in `const_impl`) doesn't actually try to compute an offset.
19091909
#[cfg_attr(not(bootstrap), allow(unused_unsafe))] // on bootstrap bump, remove unsafe block
19101910
// SAFETY: The two versions are equivalent at runtime.
19111911
unsafe {

0 commit comments

Comments
 (0)