[PATCH 0/3] rust: macros: vtable: add `#[optional]` attribute

Gary Guo <[email protected]>
Newsgroups org.kernel.vger.rust-for-linux,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
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 <[email protected]>
---
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 <[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.