Re: [PATCH v1 0/3] rust: make various `alloc` functions `const fn`
From: Miguel Ojeda
Date: Sun Jul 20 2025 - 11:43:09 EST
On Sun, Jul 20, 2025 at 5:17 PM Onur Özkan <work@xxxxxxxxxxxxx> wrote:
>
> Personally, I don't have a specific reason. I thought the change is
> harmless and might extend functionality for other people in the future.
> It could also (although less likely) help the compiler optimize things
> further.
I think it is OK -- even if we promise they are `const` and we have to
remove it in the future, it is fine, since there is no stable kernel
API. So that flexibility is another advantage of no promises there.
However, I am curious, in which cases it would help the compiler
optimize? The compiler already has the information on whether it could
actually be `const` and whether it can be evaluated at compile-time
and so on -- do you mean it has an effect on heuristics like inlining
or similar?
Thanks!
Cheers,
Miguel