[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <DFR4ZXJSZ1QO.20K98LW2161E@kernel.org>
Date: Sat, 17 Jan 2026 21:12:25 +0100
From: "Benno Lossin" <lossin@...nel.org>
To: "Gary Guo" <gary@...yguo.net>, "Miguel Ojeda" <ojeda@...nel.org>, "Boqun
Feng" <boqun.feng@...il.com>, Björn Roy Baron
<bjorn3_gh@...tonmail.com>, "Andreas Hindborg" <a.hindborg@...nel.org>,
"Alice Ryhl" <aliceryhl@...gle.com>, "Trevor Gross" <tmgross@...ch.edu>,
"Danilo Krummrich" <dakr@...nel.org>, "Luis Chamberlain"
<mcgrof@...nel.org>, "Petr Pavlu" <petr.pavlu@...e.com>, "Daniel Gomez"
<da.gomez@...nel.org>, "Sami Tolvanen" <samitolvanen@...gle.com>, "Aaron
Tomlin" <atomlin@...mlin.com>, "Tamir Duberstein" <tamird@...il.com>, "Igor
Korotin" <igor.korotin.linux@...il.com>,
José Expósito <jose.exposito89@...il.com>
Cc: <rust-for-linux@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<linux-modules@...r.kernel.org>
Subject: Re: [PATCH v3 04/12] rust: macros: use `syn` to parse `module!`
macro
On Mon Jan 12, 2026 at 6:07 PM CET, Gary Guo wrote:
> From: Gary Guo <gary@...yguo.net>
>
> With `syn` being available in the kernel, use it to parse the complex
> custom `module!` macro to replace existing helpers. Only parsing is
> changed in this commit, the code generation is untouched.
>
> This has the benefit of better error message when the macro is used
> incorrectly, as it can point to a concrete span on what's going wrong.
>
> For example, if a field is specified twice, previously it reads:
>
> error: proc macro panicked
> --> samples/rust/rust_minimal.rs:7:1
> |
> 7 | / module! {
> 8 | | type: RustMinimal,
> 9 | | name: "rust_minimal",
> 10 | | author: "Rust for Linux Contributors",
> 11 | | description: "Rust minimal sample",
> 12 | | license: "GPL",
> 13 | | license: "GPL",
> 14 | | }
> | |_^
> |
> = help: message: Duplicated key "license". Keys can only be specified once.
>
> now it reads:
>
> error: duplicated key "license". Keys can only be specified once.
> --> samples/rust/rust_minimal.rs:13:5
> |
> 13 | license: "GPL",
> | ^^^^^^^
>
> Reviewed-by: Tamir Duberstein <tamird@...il.com>
> Signed-off-by: Gary Guo <gary@...yguo.net>
Reviewed-by: Benno Lossin <lossin@...nel.org>
Cheers,
Benno
> ---
> rust/macros/helpers.rs | 109 ++++-------
> rust/macros/lib.rs | 6 +-
> rust/macros/module.rs | 399 +++++++++++++++++++++++++----------------
> 3 files changed, 280 insertions(+), 234 deletions(-)
Powered by blists - more mailing lists