Re: [PATCH 1/4] rust: alloc: replace aligned_size() with Kmalloc::aligned_layout()
From: Danilo Krummrich
Date: Sat Aug 16 2025 - 19:45:03 EST
On Sat Aug 16, 2025 at 10:40 PM CEST, Miguel Ojeda wrote:
> On Thu, Jul 31, 2025 at 5:49 PM Danilo Krummrich <dakr@xxxxxxxxxx> 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?
Yes, that's correct.
> 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.
I think it doesn't add much value for this to be a const function anyways, but
maybe it is more useful elsewhere? In that case, I think it also doesn't hurt
to Kmalloc::aligned_layout() const again.