diff options
| author | Ben Kimock <kimockb@gmail.com> | 2024-02-26 21:25:27 -0500 |
|---|---|---|
| committer | Ben Kimock <kimockb@gmail.com> | 2024-03-08 18:53:58 -0500 |
| commit | 5a93a59fd557f7d93ab0b6cc192c47580951666a (patch) | |
| tree | 79cc19acc4da1bc5b6fc7dc6cf1c7ad60d1e7737 /library/core/src/ptr/alignment.rs | |
| parent | 46b180ec2452d388c5d9c14009442e2e0beb01d7 (diff) | |
| download | rust-5a93a59fd557f7d93ab0b6cc192c47580951666a.tar.gz rust-5a93a59fd557f7d93ab0b6cc192c47580951666a.zip | |
Distinguish between library and lang UB in assert_unsafe_precondition
Diffstat (limited to 'library/core/src/ptr/alignment.rs')
| -rw-r--r-- | library/core/src/ptr/alignment.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/library/core/src/ptr/alignment.rs b/library/core/src/ptr/alignment.rs index 3508b0c7f23..8f44b7eb7c2 100644 --- a/library/core/src/ptr/alignment.rs +++ b/library/core/src/ptr/alignment.rs @@ -1,4 +1,6 @@ use crate::convert::{TryFrom, TryInto}; +#[cfg(debug_assertions)] +use crate::intrinsics::assert_unsafe_precondition; use crate::num::NonZero; use crate::{cmp, fmt, hash, mem, num}; @@ -77,9 +79,10 @@ impl Alignment { #[inline] pub const unsafe fn new_unchecked(align: usize) -> Self { #[cfg(debug_assertions)] - crate::panic::debug_assert_nounwind!( - align.is_power_of_two(), - "Alignment::new_unchecked requires a power of two" + assert_unsafe_precondition!( + check_language_ub, + "Alignment::new_unchecked requires a power of two", + (align: usize = align) => align.is_power_of_two() ); // SAFETY: By precondition, this must be a power of two, and |
