We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6dd581b commit 3ef4a60Copy full SHA for 3ef4a60
library/core/src/intrinsics.rs
@@ -2648,7 +2648,10 @@ pub(crate) use assert_unsafe_precondition;
2648
/// `align_of::<T>()`.
2649
#[inline]
2650
pub(crate) fn is_aligned_and_not_null<T>(ptr: *const T) -> bool {
2651
- !ptr.is_null() && ptr.is_aligned()
+ let mask = crate::mem::align_of::<T>() - 1;
2652
+ let is_aligned = (ptr.addr() & mask) == 0;
2653
+ let not_null = ptr.addr() != 0;
2654
+ is_aligned && not_null
2655
}
2656
2657
/// Checks whether an allocation of `len` instances of `T` exceeds
0 commit comments