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

Onur Özkan posted 3 patches 2 months, 2 weeks ago
[PATCH v1 2/3] rust: make `ArrayLayout::new_unchecked` a `const fn`
Posted by Onur Özkan 2 months, 2 weeks ago
Makes `ArrayLayout::new_unchecked` a `const fn` to allow
compile-time evaluation.

Signed-off-by: Onur Özkan <work@onurozkan.dev>
---
 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