mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/3] rust: macros: vtable: add `#[optional]` attribute
@ 2026-08-11 13:55 Gary Guo
  2026-08-11 13:55 ` [PATCH 1/3] rust: macros: vtable: hide generated `HAS_` constants for required methods Gary Guo
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Gary Guo @ 2026-08-11 13:55 UTC (permalink / raw)
  To: Miguel Ojeda, Boqun Feng, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich,
	Daniel Almeida, Tamir Duberstein, Alexandre Courbot,
	Onur Özkan, Arnd Bergmann, Greg Kroah-Hartman
  Cc: rust-for-linux, linux-kernel, Gary Guo

Currently there are a lot of boilerplate with the
`build_error!(VTABLE_DEFAULT_ERROR)` because Rust want a default
implementation but we insert `NULL` into C vtable and never call the
Rust-side method if it is not overridden.

Add an `#[optional]` attribute that injects the same default
implementation to avoid duplicating this everywhere. As an example, the
misc device vtable trait is converted.

Signed-off-by: Gary Guo <gary@garyguo.net>
---
Gary Guo (3):
      rust: macros: vtable: hide generated `HAS_` constants for required methods
      rust: macros: vtable: add `#[optional]` attribute
      rust: misc: use `#[optional]` attribute of `#[vtable]` macro

 rust/kernel/miscdevice.rs | 35 +++++++++++++----------------------
 rust/macros/lib.rs        | 39 +++++++++++----------------------------
 rust/macros/vtable.rs     | 43 ++++++++++++++++++++++++++++++++++++++-----
 3 files changed, 62 insertions(+), 55 deletions(-)
---
base-commit: 6b8c8af514d739d0335f5579b585e02babe8a727
change-id: 20260811-vtable_macro-12a8f557381b

Best regards,
--  
Gary Guo <gary@garyguo.net>


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

end of thread, other threads:[~2026-10-02 20:37 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-11 13:55 [PATCH 0/3] rust: macros: vtable: add `#[optional]` attribute Gary Guo
2026-08-11 13:55 ` [PATCH 1/3] rust: macros: vtable: hide generated `HAS_` constants for required methods Gary Guo
2026-08-11 13:55 ` [PATCH 2/3] rust: macros: vtable: add `#[optional]` attribute Gary Guo
2026-08-11 13:55 ` [PATCH 3/3] rust: misc: use `#[optional]` attribute of `#[vtable]` macro Gary Guo
2026-10-02 13:17   ` Miguel Ojeda
2026-10-02 13:55     ` Greg Kroah-Hartman
2026-10-02 19:10 ` [PATCH 0/3] rust: macros: vtable: add `#[optional]` attribute Miguel Ojeda
2026-10-02 20:37   ` Gary Guo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®