Skip to content

rust: macros: vtable: add `#[optional]` attribute

Gary Guo lkml rust-for-linux 1 version Applied

Status from this message: Applied to `rust-next` -- thanks everyone!

Get series with b4
b4 am [email protected] change-id 20260811-vtable_macro-12a8f557381b

Versions newest first

  1. v1 Latest3 patches 4 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/3rust: macros: vtable: hide generated `HAS_` constants for required methodsrust/macros/vtable.rs+13 -40 replies
2/3rust: macros: vtable: add `#[optional]` attributerust/macros/lib.rs rust/macros/vtable.rs+36 -290 replies
3/3rust: misc: use `#[optional]` attribute of `#[vtable]` macrorust/kernel/miscdevice.rs+13 -222 replies

Reviews trailers per patch

1 of 3 patches has a Reviewed-by or Acked-by.

PatchGreg Kroah-Hartman
1/3
2/3
3/3A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

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

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.

---
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,

Signature · 1 line
Gary Guo <[email protected]>