rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 0/6] add `syn` versions of pin-init macros
@ 2025-03-04 22:56 Benno Lossin
  2025-03-04 22:56 ` [RFC PATCH 1/6] rust: pin-init: internal: add syn version of the `Zeroable` derive macro Benno Lossin
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Benno Lossin @ 2025-03-04 22:56 UTC (permalink / raw)
  To: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich
  Cc: rust-for-linux

Change the implementations of all pin-init macros to use `syn` [1]. It
is a library to make parsing Rust code in proc-macros simple. Since the
kernel does not yet depend on syn, only the user-space version will
benefit from this change now. However, we will soon add `syn` as a
dependency using the new build system. `syn` is used by almost all
proc-macros in the Rust ecosystem and even by the Rust compiler itself!

There are a lot of benefits to writing proc-macros using `syn`.
Parsing is a lot more readable and thus maintainable. The benefit in
simplicity can then be taken advantage of by extending the syntax. I
plan to support tuple structs soon. Another benefit is the increased
readability in the errors on malformed macro-input. Currently they are
very bad, because they come from token-munching declarative macros,
which are notorious for bad error messages. See the respective commit
messages for examples.

---
Cheers,
Benno

[1]: https://crates.io/crates/syn

Benno Lossin (6):
  rust: pin-init: internal: add syn version of the `Zeroable` derive
    macro
  rust: pin-init: internal: add syn version of `pinned_drop` proc macro
  rust: pin-init: internal: add syn version of the `pin_data` proc macro
  rust: pin-init: add `?Sized` bounds to traits in `#[pin_data]` macro
  rust: pin-init: allow doctests to refer to the pin-init crate
  rust: pin-init: internal: add syn version of `[try_][pin_]init!`
    macros

 rust/pin-init/internal/src/init.rs            | 404 ++++++++++++++++++
 rust/pin-init/internal/src/lib.rs             |  96 ++++-
 rust/pin-init/internal/src/syn_pin_data.rs    | 313 ++++++++++++++
 rust/pin-init/internal/src/syn_pinned_drop.rs |  77 ++++
 rust/pin-init/internal/src/syn_zeroable.rs    |  63 +++
 rust/pin-init/src/__internal.rs               |  62 +++
 rust/pin-init/src/lib.rs                      |  69 +--
 rust/pin-init/src/macros.rs                   |   4 +-
 8 files changed, 1020 insertions(+), 68 deletions(-)
 create mode 100644 rust/pin-init/internal/src/init.rs
 create mode 100644 rust/pin-init/internal/src/syn_pin_data.rs
 create mode 100644 rust/pin-init/internal/src/syn_pinned_drop.rs
 create mode 100644 rust/pin-init/internal/src/syn_zeroable.rs


base-commit: 0cdd06928bd97cdbfa7061a52cc91901c84d9b2f
-- 
2.48.1



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

end of thread, other threads:[~2025-03-04 22:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-04 22:56 [RFC PATCH 0/6] add `syn` versions of pin-init macros Benno Lossin
2025-03-04 22:56 ` [RFC PATCH 1/6] rust: pin-init: internal: add syn version of the `Zeroable` derive macro Benno Lossin
2025-03-04 22:57 ` [RFC PATCH 2/6] rust: pin-init: internal: add syn version of `pinned_drop` proc macro Benno Lossin
2025-03-04 22:57 ` [RFC PATCH 3/6] rust: pin-init: internal: add syn version of the `pin_data` " Benno Lossin
2025-03-04 22:57 ` [RFC PATCH 4/6] rust: pin-init: add `?Sized` bounds to traits in `#[pin_data]` macro Benno Lossin
2025-03-04 22:57 ` [RFC PATCH 5/6] rust: pin-init: allow doctests to refer to the pin-init crate Benno Lossin
2025-03-04 22:57 ` [RFC PATCH 6/6] rust: pin-init: internal: add syn version of `[try_][pin_]init!` macros 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).