@@ -109,15 +109,15 @@ pub(crate) const fn check_language_ub() -> bool { |
|
|
109 |
109 |
intrinsics::ub_checks() && const_eval_select((), comptime, runtime) |
110 |
110 |
} |
111 |
111 |
|
112 |
|
-/// Checks whether `ptr` is properly aligned with respect to |
113 |
|
-/// `align_of::()`. |
|
112 |
+/// Checks whether `ptr` is properly aligned with respect to the given alignment, and |
|
113 |
+/// if `is_zst == false`, that `ptr` is not null. |
114 |
114 |
/// |
115 |
115 |
/// In `const` this is approximate and can fail spuriously. It is primarily intended |
116 |
116 |
/// for `assert_unsafe_precondition!` with `check_language_ub`, in which case the |
117 |
117 |
/// check is anyway not executed in `const`. |
118 |
118 |
#[inline] |
119 |
119 |
pub(crate) const fn is_aligned_and_not_null(ptr: *const (), align: usize, is_zst: bool) -> bool { |
120 |
|
-if is_zst { ptr.is_aligned_to(align) } else { !ptr.is_null() && ptr.is_aligned_to(align) } |
|
120 |
+ ptr.is_aligned_to(align) && (is_zst | |
121 |
121 |
} |
122 |
122 |
|
123 |
123 |
#[inline] |