On Thu, Jul 31, 2025 at 5:49 PM Danilo Krummrich <d...@kernel.org> wrote: > > +impl Kmalloc { > + /// Returns a [`Layout`] that makes [`Kmalloc`] fulfill the requested > size and alignment of > + /// `layout`. > + pub const fn aligned_layout(layout: Layout) -> Layout {
I think this `const fn` here was removed when applying to make it work with older compilers, right? I was fixing another `rusttest` thing and noticed while applying these. I had a patch to fix it, since we can actually just use the feature, and then I noticed it wasn't in the tree. Since I have it, I am attaching it for reference in case the now-stable feature is needed, e.g. if you want to make that `const fn` again. Cheers, Miguel
From 3cf24f05614e33493ba086bab1f02f701c894807 Mon Sep 17 00:00:00 2001 From: Miguel Ojeda <ojeda@kernel.org> Date: Sat, 16 Aug 2025 22:20:29 +0200 Subject: [NOT PATCH] rust: kernel: use `const_alloc_layout` feature to fix Rust < 1.85 builds Before Rust 1.85.0 (released 2025-02-20), `pad_to_align` was not available in const contexts: error: `core::alloc::Layout::pad_to_align` is not yet stable as a const fn --> rust/kernel/alloc/allocator.rs:122:9 | 122 | layout.pad_to_align() | ^^^^^^^^^^^^^^^^^^^^^ | = help: add `#![feature(const_alloc_layout)]` to the crate attributes to enable Since the `const_alloc_layout` feature [1] is already stable [2] and is available in our minimum Rust version too, simply add it to the list of the ones we use. Link: https://github.com/rust-lang/rust/issues/67521 [1] Link: https://github.com/rust-lang/rust/pull/134768 [2] Not-Fixes (patch was changed on apply): fde578c86281 ("rust: alloc: replace aligned_size() with Kmalloc::aligned_layout()") Link: 20250731154919.4132-2-dakr@kernel.org/">https://lore.kernel.org/rust-for-linux/20250731154919.4132-2-dakr@kernel.org/ Signed-off-by: Miguel Ojeda <ojeda@kernel.org> --- rust/kernel/lib.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rust/kernel/lib.rs b/rust/kernel/lib.rs index ed53169e795c..94d174ed7b8b 100644 --- a/rust/kernel/lib.rs +++ b/rust/kernel/lib.rs @@ -31,6 +31,9 @@ #![feature(const_ptr_write)] #![feature(const_refs_to_cell)] // +// Stable since Rust 1.85.0. +#![feature(const_alloc_layout)] +// // Expected to become stable. #![feature(arbitrary_self_types)] // -- 2.50.1