[PATCH v1 2/3] rust: make `ArrayLayout::new_unchecked` a `const fn`

From: Onur Özkan
Date: Sun Jul 20 2025 - 05:49:22 EST


Makes `ArrayLayout::new_unchecked` a `const fn` to allow
compile-time evaluation.

Signed-off-by: Onur Özkan <work@xxxxxxxxxxxxx>
---
rust/kernel/alloc/layout.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rust/kernel/alloc/layout.rs b/rust/kernel/alloc/layout.rs
index 93ed514f7cc7..52cbf61c4539 100644
--- a/rust/kernel/alloc/layout.rs
+++ b/rust/kernel/alloc/layout.rs
@@ -80,7 +80,7 @@ pub const fn new(len: usize) -> Result<Self, LayoutError> {
/// # Safety
///
/// `len` must be a value, for which `len * size_of::<T>() <= isize::MAX` is true.
- pub unsafe fn new_unchecked(len: usize) -> Self {
+ pub const unsafe fn new_unchecked(len: usize) -> Self {
// INVARIANT: By the safety requirements of this function
// `len * size_of::<T>() <= isize::MAX`.
Self {
--
2.50.0