Re: [PATCH] rust: devres: use compile-time type_name for debug info

From: Gary Guo

Date: Wed May 27 2026 - 07:04:36 EST


On Tue May 26, 2026 at 10:43 AM BST, Aary Milind Kinge wrote:
> From: Not-Buddy <kingeaary@xxxxxxxxx>
>
> The devres_set_node_dbginfo function previously used a hardcoded
> c"Devres<T>" string for all device resource nodes because
> core::any::type_name was not stabilized as a const fn. This made
> debugging device resources difficult as all nodes shared the same name.
>
> Enable the `const_type_name` unstable feature in the `kernel` crate
> and replace the hardcoded placeholder with the actual generic type
> name at compile time.

NACK. The feature is not stable on latest rustc and is unclear that it is
planned to be stabilised, so we cannot just enable and use it.

If you want to enable this feature for kernel, you should first try to help
moving the stabilization forward on the Rust side.

Thanks,
Gary

>
> To satisfy the C-API's requirement for a null-terminated string, the
> bytes are copied into a locally evaluated const array buffer, appended
> with a null byte, and promoted to static read-only memory by reference
> before being passed to devres_set_node_dbginfo.
>
> Signed-off-by: Aary Milind Kinge <kingeaary@xxxxxxxxx>
> ---
> rust/kernel/devres.rs | 41 ++++++++++++++++++++++++++++++++++++++---
> rust/kernel/lib.rs | 1 +
> 2 files changed, 39 insertions(+), 3 deletions(-)