diff options
| author | Thom Chiovoloni <chiovolonit@gmail.com> | 2022-05-27 22:19:43 -0700 |
|---|---|---|
| committer | Thom Chiovoloni <chiovolonit@gmail.com> | 2022-05-27 22:19:43 -0700 |
| commit | 25164b4e51a6ad3d421b139ce40872dd1892750c (patch) | |
| tree | 76a31c190fb31a4dbb4cd24c8b3f2b7a159c3316 | |
| parent | fc109bb6c68f59903dace87c69bdeb2df5a006f0 (diff) | |
| download | rust-25164b4e51a6ad3d421b139ce40872dd1892750c.tar.gz rust-25164b4e51a6ad3d421b139ce40872dd1892750c.zip | |
Use `pointer::is_aligned` in ThinBox debug assert
| -rw-r--r-- | library/alloc/src/boxed/thin.rs | 2 | ||||
| -rw-r--r-- | library/alloc/src/lib.rs | 1 |
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))] |
