Use pointer::is_aligned in ThinBox debug assert

This commit is contained in:
Thom Chiovoloni 2022-05-27 22:19:43 -07:00
parent fc109bb6c6
commit 25164b4e51
No known key found for this signature in database
GPG key ID: E2EFD4309E11C8A8
2 changed files with 2 additions and 1 deletions

View file

@ -224,7 +224,7 @@ impl<H> WithHeader<H> {
// will always result in an aligned header pointer, it just may not point to the // will always result in an aligned header pointer, it just may not point to the
// beginning of the allocation. // beginning of the allocation.
let hp = unsafe { self.0.as_ptr().sub(Self::header_size()) as *mut H }; 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 hp
} }

View file

@ -168,6 +168,7 @@
#![feature(nll)] // Not necessary, but here to test the `nll` feature. #![feature(nll)] // Not necessary, but here to test the `nll` feature.
#![feature(rustc_allow_const_fn_unstable)] #![feature(rustc_allow_const_fn_unstable)]
#![feature(rustc_attrs)] #![feature(rustc_attrs)]
#![feature(pointer_is_aligned)]
#![feature(slice_internals)] #![feature(slice_internals)]
#![feature(staged_api)] #![feature(staged_api)]
#![cfg_attr(test, feature(test))] #![cfg_attr(test, feature(test))]