[PATCH v1 1/3] rust: make `allocator::aligned_size` a `const fn`

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


Makes `allocator::aligned_size` a `const fn` to allow
compile-time evaluation.

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

diff --git a/rust/kernel/alloc/allocator.rs b/rust/kernel/alloc/allocator.rs
index aa2dfa9dca4c..aa2957fd585b 100644
--- a/rust/kernel/alloc/allocator.rs
+++ b/rust/kernel/alloc/allocator.rs
@@ -44,7 +44,7 @@
pub struct KVmalloc;

/// Returns a proper size to alloc a new object aligned to `new_layout`'s alignment.
-fn aligned_size(new_layout: Layout) -> usize {
+const fn aligned_size(new_layout: Layout) -> usize {
// Customized layouts from `Layout::from_size_align()` can have size < align, so pad first.
let layout = new_layout.pad_to_align();

--
2.50.0