rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/11] refactor Rust proc macros with `syn`
@ 2025-12-11 18:56 Gary Guo
  2025-12-11 18:56 ` [PATCH 01/11] rust: pin-init: internal: remove proc-macro[2] and quote workarounds Gary Guo
                   ` (10 more replies)
  0 siblings, 11 replies; 17+ messages in thread
From: Gary Guo @ 2025-12-11 18:56 UTC (permalink / raw)
  To: Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Danilo Krummrich
  Cc: rust-for-linux

From: Gary Guo <gary@garyguo.net>

This series convert Rust proc macros that we have with `syn`, and replace the
custom `quote!` macro that we have with the vendored `quote!` macro. The
`pin-init` macros are not converted `syn` yet; Benno has a work in progress in
converting them. They're however converted to use `quote` and `proc-macro2`
crate so our custom `quote!` macro can be removed.

Overall this improves the robustness of the macros as we have precise parsing of
the AST rather than relying on heuristics to extract needed information from
there. This is also a quality-of-life improvement to those using language
servers (e.g. Rust analyzer) as the span information of the proc macros are now
preserved which allows the "jump-to-definition" feature to work, even when used
on completely custom macros such as `module!`.

Miguel gave a very good explaination on why `syn` is a good idea in the patch
series that introduced it [1], which I shall not repeat here.

Link: https://lore.kernel.org/rust-for-linux/20251124151837.2184382-1-ojeda@kernel.org/ [1]

Benno Lossin (1):
  rust: pin-init: internal: remove proc-macro[2] and quote workarounds

Gary Guo (10):
  rust: macros: use `quote!` from vendored crate
  rust: macros: convert `#[vtable]` macro to use `syn`
  rust: macros: use `syn` to parse `module!` macro
  rust: macros: use `quote!` for `module!` macro
  rust: macros: convert `#[export]` to use `syn`
  rust: macros: convert `concat_idents!` to use `syn`
  rust: macros: convert `#[kunit_tests]` macro to use `syn`
  rust: macros: allow arbitrary types to be used in `module!` macro
  rust: macros: rearrange `#[doc(hidden)]` in `module!` macro
  rust: kunit: use `pin_init::zeroed` instead of custom null value

 rust/Makefile                             |  16 +-
 rust/kernel/kunit.rs                      |  26 +-
 rust/macros/concat_idents.rs              |  39 +-
 rust/macros/export.rs                     |  26 +-
 rust/macros/fmt.rs                        |   4 +-
 rust/macros/helpers.rs                    | 104 +---
 rust/macros/kunit.rs                      | 275 ++++------
 rust/macros/lib.rs                        |  44 +-
 rust/macros/module.rs                     | 638 +++++++++++++---------
 rust/macros/paste.rs                      |   2 +-
 rust/macros/quote.rs                      | 182 ------
 rust/macros/vtable.rs                     | 154 +++---
 rust/pin-init/internal/src/helpers.rs     |   5 +-
 rust/pin-init/internal/src/lib.rs         |  16 -
 rust/pin-init/internal/src/pin_data.rs    |   6 +-
 rust/pin-init/internal/src/pinned_drop.rs |   6 +-
 rust/pin-init/internal/src/zeroable.rs    |   6 +-
 scripts/generate_rust_analyzer.py         |   2 +-
 18 files changed, 694 insertions(+), 857 deletions(-)
 delete mode 100644 rust/macros/quote.rs


base-commit: 559e608c46553c107dbba19dae0854af7b219400
-- 
2.51.2


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2025-12-16 12:49 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-11 18:56 [PATCH 00/11] refactor Rust proc macros with `syn` Gary Guo
2025-12-11 18:56 ` [PATCH 01/11] rust: pin-init: internal: remove proc-macro[2] and quote workarounds Gary Guo
2025-12-11 21:50   ` Christian Schrefl
2025-12-15 13:01     ` Gary Guo
2025-12-16  9:43       ` Benno Lossin
2025-12-11 18:56 ` [PATCH 02/11] rust: macros: use `quote!` from vendored crate Gary Guo
2025-12-16  9:47   ` Benno Lossin
2025-12-11 18:56 ` [PATCH 03/11] rust: macros: convert `#[vtable]` macro to use `syn` Gary Guo
2025-12-11 18:56 ` [PATCH 04/11] rust: macros: use `syn` to parse `module!` macro Gary Guo
2025-12-11 18:56 ` [PATCH 05/11] rust: macros: use `quote!` for " Gary Guo
2025-12-11 18:56 ` [PATCH 06/11] rust: macros: convert `#[export]` to use `syn` Gary Guo
2025-12-11 18:56 ` [PATCH 07/11] rust: macros: convert `concat_idents!` " Gary Guo
2025-12-11 18:56 ` [PATCH 08/11] rust: macros: convert `#[kunit_tests]` macro " Gary Guo
2025-12-11 18:56 ` [PATCH 09/11] rust: macros: allow arbitrary types to be used in `module!` macro Gary Guo
2025-12-11 18:56 ` [PATCH 10/11] rust: macros: rearrange `#[doc(hidden)]` " Gary Guo
2025-12-11 18:56 ` [PATCH 11/11] rust: kunit: use `pin_init::zeroed` instead of custom null value Gary Guo
2025-12-16 12:48   ` Benno Lossin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).