Enable Alignment::new_unchecked precondition check

This commit is contained in:
Ben Kimock 2024-08-23 18:26:45 -04:00
parent eef00c8be8
commit 5d98d20529

View File

@ -1,5 +1,4 @@
use crate::num::NonZero; use crate::num::NonZero;
#[cfg(debug_assertions)]
use crate::ub_checks::assert_unsafe_precondition; use crate::ub_checks::assert_unsafe_precondition;
use crate::{cmp, fmt, hash, mem, num}; use crate::{cmp, fmt, hash, mem, num};
@ -77,7 +76,6 @@ pub const fn new(align: usize) -> Option<Self> {
#[rustc_const_unstable(feature = "ptr_alignment_type", issue = "102070")] #[rustc_const_unstable(feature = "ptr_alignment_type", issue = "102070")]
#[inline] #[inline]
pub const unsafe fn new_unchecked(align: usize) -> Self { pub const unsafe fn new_unchecked(align: usize) -> Self {
#[cfg(debug_assertions)]
assert_unsafe_precondition!( assert_unsafe_precondition!(
check_language_ub, check_language_ub,
"Alignment::new_unchecked requires a power of two", "Alignment::new_unchecked requires a power of two",