about summary refs log tree commit diff
diff options
context:
space:
mode:
authorThom Chiovoloni <chiovolonit@gmail.com>2022-05-27 22:19:43 -0700
committerThom Chiovoloni <chiovolonit@gmail.com>2022-05-27 22:19:43 -0700
commit25164b4e51a6ad3d421b139ce40872dd1892750c (patch)
tree76a31c190fb31a4dbb4cd24c8b3f2b7a159c3316
parentfc109bb6c68f59903dace87c69bdeb2df5a006f0 (diff)
downloadrust-25164b4e51a6ad3d421b139ce40872dd1892750c.tar.gz
rust-25164b4e51a6ad3d421b139ce40872dd1892750c.zip
Use `pointer::is_aligned` in ThinBox debug assert
-rw-r--r--library/alloc/src/boxed/thin.rs2
-rw-r--r--library/alloc/src/lib.rs1
2 files changed, 2 insertions, 1 deletions
diff --git a/library/alloc/src/boxed/thin.rs b/library/alloc/src/boxed/thin.rs
index 703a28cf2de..807c035fdbd 100644
--- a/library/alloc/src/boxed/thin.rs
+++ b/library/alloc/src/boxed/thin.rs
@@ -224,7 +224,7 @@ impl<H> WithHeader<H> {
         //    will always result in an aligned header pointer, it just may not point to the
         //    beginning of the allocation.
         let hp = unsafe { self.0.as_ptr().sub(Self::header_size()) as *mut H };
-        debug_assert!((hp.addr() & (core::mem::align_of::<H>() - 1)) == 0);
+        debug_assert!(hp.is_aligned());
         hp
     }
 
diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs
index fd21b367118..9c25c572a68 100644
--- a/library/alloc/src/lib.rs
+++ b/library/alloc/src/lib.rs
@@ -168,6 +168,7 @@
 #![feature(nll)] // Not necessary, but here to test the `nll` feature.
 #![feature(rustc_allow_const_fn_unstable)]
 #![feature(rustc_attrs)]
+#![feature(pointer_is_aligned)]
 #![feature(slice_internals)]
 #![feature(staged_api)]
 #![cfg_attr(test, feature(test))]