about summary refs log tree commit diff
path: root/library/alloc
diff options
context:
space:
mode:
authorMaybe Waffle <waffle.lapkin@gmail.com>2022-08-19 13:26:37 +0400
committerMaybe Waffle <waffle.lapkin@gmail.com>2022-08-21 15:46:03 +0400
commitefef211876b193ebc5e33dc9414c5a3dc14e9739 (patch)
tree14f041a2c9702f9392b9fbf40ed6ff9e9f0d50cd /library/alloc
parented084ba292609da9fe05808f186b72453013c094 (diff)
downloadrust-efef211876b193ebc5e33dc9414c5a3dc14e9739.tar.gz
rust-efef211876b193ebc5e33dc9414c5a3dc14e9739.zip
Make use of `pointer::is_aligned[_to]`
Diffstat (limited to 'library/alloc')
-rw-r--r--library/alloc/tests/lib.rs1
-rw-r--r--library/alloc/tests/thin_box.rs8
2 files changed, 5 insertions, 4 deletions
diff --git a/library/alloc/tests/lib.rs b/library/alloc/tests/lib.rs
index d83cd29ddba..99bfb2a45ed 100644
--- a/library/alloc/tests/lib.rs
+++ b/library/alloc/tests/lib.rs
@@ -38,6 +38,7 @@
 #![feature(const_str_from_utf8)]
 #![feature(nonnull_slice_from_raw_parts)]
 #![feature(panic_update_hook)]
+#![feature(pointer_is_aligned)]
 #![feature(slice_flatten)]
 #![feature(thin_box)]
 #![feature(bench_black_box)]
diff --git a/library/alloc/tests/thin_box.rs b/library/alloc/tests/thin_box.rs
index 368aa564f94..e008b0cc357 100644
--- a/library/alloc/tests/thin_box.rs
+++ b/library/alloc/tests/thin_box.rs
@@ -48,11 +48,11 @@ fn verify_aligned<T>(ptr: *const T) {
     // practice these checks are mostly just smoke-detectors for an extremely
     // broken `ThinBox` impl, since it's an extremely subtle piece of code.
     let ptr = core::hint::black_box(ptr);
-    let align = core::mem::align_of::<T>();
     assert!(
-        (ptr.addr() & (align - 1)) == 0 && !ptr.is_null(),
-        "misaligned ThinBox data; valid pointers to `{}` should be aligned to {align}: {ptr:p}",
-        core::any::type_name::<T>(),
+        ptr.is_aligned() && !ptr.is_null(),
+        "misaligned ThinBox data; valid pointers to `{ty}` should be aligned to {align}: {ptr:p}",
+        ty = core::any::type_name::<T>(),
+        align = core::mem::align_of::<T>(),
     );
 }