Skip to content

Commit 84b1b49

Browse files
Gnurouojeda
authored andcommitted
rust: ptr: replace unneeded use of build_assert
Since `ALIGN` is a const parameter, this assertion can be done in const context using the `assert!` macro. Suggested-by: Alice Ryhl <aliceryhl@google.com> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Link: https://patch.msgid.link/20251216-ptr_assert-v1-1-d8b2d5c5741d@nvidia.com Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
1 parent 1b18b37 commit 84b1b49

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

rust/kernel/ptr.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
use core::mem::align_of;
66
use core::num::NonZero;
77

8-
use crate::build_assert;
9-
108
/// Type representing an alignment, which is always a power of two.
119
///
1210
/// It is used to validate that a given value is a valid alignment, and to perform masking and
@@ -40,10 +38,12 @@ impl Alignment {
4038
/// ```
4139
#[inline(always)]
4240
pub const fn new<const ALIGN: usize>() -> Self {
43-
build_assert!(
44-
ALIGN.is_power_of_two(),
45-
"Provided alignment is not a power of two."
46-
);
41+
const {
42+
assert!(
43+
ALIGN.is_power_of_two(),
44+
"Provided alignment is not a power of two."
45+
);
46+
}
4747

4848
// INVARIANT: `align` is a power of two.
4949
// SAFETY: `align` is a power of two, and thus non-zero.

0 commit comments

Comments
 (0)