Re: [PATCH v2 0/3] rust: const_eval: add a mechanism to do const trait calls
From: Miguel Ojeda
Date: Thu Sep 03 2026 - 12:51:11 EST
On Thu, Sep 3, 2026 at 5:21 PM Gary Guo <gary@xxxxxxxxxxx> wrote:
>
> Add a mechanism to perform const trait method calls, with the same type
> inference capabilities. This would only work for concrete types (not inside
> generic functions).
>
> As an example, convert `as_char_ptr_in_const_context`, so instead of
>
> kernel::str::as_char_ptr_in_const_context(c_str)
>
> one may write
>
> const_call!(c_str.as_char_ptr())
>
> instead.
>
> Signed-off-by: Gary Guo <gary@xxxxxxxxxxx>
Thanks for resending this!
So I definitely like having `#[const_eval_only]`, because we do want
to limit those calls sometimes and it is nice to have C++'s equivalent
to `consteval` (perhaps this could be called just `#[consteval]` to
match?); i.e. what we talked about in the call.
On `Const` and `const_call!`, i.e. the other two patches: I am not
sure if we care that much to introduce a macro for it, but it doesn't
look bad either. I guess perhaps it helps to have a consistent way to
do it and to easily remove it later when the actual feature lands in
Rust. I would like to hear some thoughts on it from others.
Cheers,
Miguel