about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMaybe Waffle <waffle.lapkin@gmail.com>2022-04-15 01:58:59 +0400
committerMaybe Waffle <waffle.lapkin@gmail.com>2022-05-12 12:54:21 +0400
commit6c1ebff59e5c92eadd1ed5d986c36e34791d6ed3 (patch)
treeab5b0ce80b6f1ae57c96b76b1e59a9bfb5a9f07f
parenta908eec4389137bcaefb2bad6eb1efb34cb1be2d (diff)
downloadrust-6c1ebff59e5c92eadd1ed5d986c36e34791d6ed3.tar.gz
rust-6c1ebff59e5c92eadd1ed5d986c36e34791d6ed3.zip
Implement `ptr.is_aligned()` in terms of `.is_aligned_to()`
-rw-r--r--library/core/src/ptr/const_ptr.rs2
-rw-r--r--library/core/src/ptr/mut_ptr.rs2
2 files changed, 2 insertions, 2 deletions
diff --git a/library/core/src/ptr/const_ptr.rs b/library/core/src/ptr/const_ptr.rs
index 0d936eacc51..9bbdfd1cbb5 100644
--- a/library/core/src/ptr/const_ptr.rs
+++ b/library/core/src/ptr/const_ptr.rs
@@ -1301,7 +1301,7 @@ impl<T: ?Sized> *const T {
     where
         T: Sized,
     {
-        self.addr() % core::mem::align_of::<T>() == 0
+        self.is_aligned_to(core::mem::align_of::<T>())
     }
 
     /// Returns whether the pointer is aligned to `align`.
diff --git a/library/core/src/ptr/mut_ptr.rs b/library/core/src/ptr/mut_ptr.rs
index d223d76ac3a..21220e2a486 100644
--- a/library/core/src/ptr/mut_ptr.rs
+++ b/library/core/src/ptr/mut_ptr.rs
@@ -1570,7 +1570,7 @@ impl<T: ?Sized> *mut T {
     where
         T: Sized,
     {
-        self.addr() % core::mem::align_of::<T>() == 0
+        self.is_aligned_to(core::mem::align_of::<T>())
     }
 
     /// Returns whether the pointer is aligned to `align`.