From 1082c36a4c734972a13734c7e9565a5f2b9fc79a Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 9 Mar 2024 11:54:27 +0100 Subject: [PATCH] fn is_align_to: move some comments closer to the cast they refer to --- library/core/src/ptr/const_ptr.rs | 6 +++--- library/core/src/ptr/mut_ptr.rs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/library/core/src/ptr/const_ptr.rs b/library/core/src/ptr/const_ptr.rs index 0c69bf2aef9c1..90dbc798fcf18 100644 --- a/library/core/src/ptr/const_ptr.rs +++ b/library/core/src/ptr/const_ptr.rs @@ -1628,12 +1628,12 @@ impl *const T { #[inline] const fn const_impl(ptr: *const (), align: usize) -> bool { // We can't use the address of `self` in a `const fn`, so we use `align_offset` instead. - // The cast to `()` is used to - // 1. deal with fat pointers; and - // 2. ensure that `align_offset` doesn't actually try to compute an offset. ptr.align_offset(align) == 0 } + // The cast to `()` is used to + // 1. deal with fat pointers; and + // 2. ensure that `align_offset` (in `const_impl`) doesn't actually try to compute an offset. #[cfg_attr(not(bootstrap), allow(unused_unsafe))] // on bootstrap bump, remove unsafe block // SAFETY: The two versions are equivalent at runtime. unsafe { diff --git a/library/core/src/ptr/mut_ptr.rs b/library/core/src/ptr/mut_ptr.rs index 5ce3b1f298cba..6a9033a144deb 100644 --- a/library/core/src/ptr/mut_ptr.rs +++ b/library/core/src/ptr/mut_ptr.rs @@ -1900,12 +1900,12 @@ impl *mut T { #[inline] const fn const_impl(ptr: *mut (), align: usize) -> bool { // We can't use the address of `self` in a `const fn`, so we use `align_offset` instead. - // The cast to `()` is used to - // 1. deal with fat pointers; and - // 2. ensure that `align_offset` doesn't actually try to compute an offset. ptr.align_offset(align) == 0 } + // The cast to `()` is used to + // 1. deal with fat pointers; and + // 2. ensure that `align_offset` (in `const_impl`) doesn't actually try to compute an offset. #[cfg_attr(not(bootstrap), allow(unused_unsafe))] // on bootstrap bump, remove unsafe block // SAFETY: The two versions are equivalent at runtime. unsafe {