From 25164b4e51a6ad3d421b139ce40872dd1892750c Mon Sep 17 00:00:00 2001 From: Thom Chiovoloni Date: Fri, 27 May 2022 22:19:43 -0700 Subject: [PATCH] Use `pointer::is_aligned` in ThinBox debug assert --- library/alloc/src/boxed/thin.rs | 2 +- library/alloc/src/lib.rs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/library/alloc/src/boxed/thin.rs b/library/alloc/src/boxed/thin.rs index 703a28cf2de6c..807c035fdbd0d 100644 --- a/library/alloc/src/boxed/thin.rs +++ b/library/alloc/src/boxed/thin.rs @@ -224,7 +224,7 @@ impl WithHeader { // 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::() - 1)) == 0); + debug_assert!(hp.is_aligned()); hp } diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs index fd21b3671182b..9c25c572a689d 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))]