[PATCH 10/17] rust: macros: replace `kernel::c_str!` with C-Strings

Tamir Duberstein tamird at gmail.com
Thu Jul 10 15:31:13 UTC 2025


C-String literals were added in Rust 1.77. Replace instances of
`kernel::c_str!` with C-String literals where possible.

Acked-by: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
Reviewed-by: Alice Ryhl <aliceryhl at google.com>
Signed-off-by: Tamir Duberstein <tamird at gmail.com>
---
 rust/macros/module.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rust/macros/module.rs b/rust/macros/module.rs
index 5dd276a2e5cb..532342a38b6f 100644
--- a/rust/macros/module.rs
+++ b/rust/macros/module.rs
@@ -228,7 +228,7 @@ pub(crate) fn module(ts: TokenStream) -> TokenStream {
             type LocalModule = {type_};
 
             impl ::kernel::ModuleMetadata for {type_} {{
-                const NAME: &'static ::kernel::str::CStr = ::kernel::c_str!(\"{name}\");
+                const NAME: &'static ::kernel::str::CStr = c\"{name}\";
             }}
 
             // Double nested modules, since then nobody can access the public items inside.

-- 
2.50.0



More information about the dri-devel mailing list