On Mon Jan 12, 2026 at 6:07 PM CET, Gary Guo wrote: > From: Gary Guo <[email protected]> > > 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 <[email protected]> > Signed-off-by: Gary Guo <[email protected]>
Reviewed-by: Benno Lossin <[email protected]> Cheers, Benno > --- > rust/macros/helpers.rs | 109 ++++------- > rust/macros/lib.rs | 6 +- > rust/macros/module.rs | 399 +++++++++++++++++++++++++---------------- > 3 files changed, 280 insertions(+), 234 deletions(-)

