fn is_align_to: move some comments closer to the cast they refer to
This commit is contained in:
parent
6aff1ca68c
commit
1082c36a4c
@ -1628,12 +1628,12 @@ impl<T: ?Sized> *const T {
|
|||||||
#[inline]
|
#[inline]
|
||||||
const fn const_impl(ptr: *const (), align: usize) -> bool {
|
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.
|
// 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
|
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
|
#[cfg_attr(not(bootstrap), allow(unused_unsafe))] // on bootstrap bump, remove unsafe block
|
||||||
// SAFETY: The two versions are equivalent at runtime.
|
// SAFETY: The two versions are equivalent at runtime.
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -1900,12 +1900,12 @@ impl<T: ?Sized> *mut T {
|
|||||||
#[inline]
|
#[inline]
|
||||||
const fn const_impl(ptr: *mut (), align: usize) -> bool {
|
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.
|
// 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
|
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
|
#[cfg_attr(not(bootstrap), allow(unused_unsafe))] // on bootstrap bump, remove unsafe block
|
||||||
// SAFETY: The two versions are equivalent at runtime.
|
// SAFETY: The two versions are equivalent at runtime.
|
||||||
unsafe {
|
unsafe {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user