From: "Gary Guo" <gary@garyguo.net>
To: "Miguel Ojeda" <miguel.ojeda.sandonis@gmail.com>,
"Gary Guo" <gary@garyguo.net>
Cc: "Miguel Ojeda" <ojeda@kernel.org>,
"Boqun Feng" <boqun@kernel.org>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Tamir Duberstein" <tamird@kernel.org>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Onur Özkan" <work@onurozkan.dev>,
"Arnd Bergmann" <arnd@arndb.de>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 0/3] rust: macros: vtable: add `#[optional]` attribute
Date: Fri, 02 Oct 2026 21:37:44 +0100 [thread overview]
Message-ID: <DLUN3V3VNRZC.1PML6OCVBP2TN@garyguo.net> (raw)
In-Reply-To: <CANiq72neqitKHftQ9UVJaKLkcUdX8uAWLtoE08-G784mqX+H9w@mail.gmail.com>
On Fri Oct 2, 2026 at 8:10 PM BST, Miguel Ojeda wrote:
> On Tue, Aug 11, 2026 at 3:56 PM Gary Guo <gary@garyguo.net> wrote:
>>
>> 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>
>
> Applied to `rust-next` -- thanks everyone!
>
> [ Reworded for typo. - Miguel ]
>
> [ Rewrapped docs. Reworded message, comment and error for typos. Rebased.
> - Miguel ]
>
> [ Reworded title for prefix. - Miguel ]
>
> I was tempted to replace the hardcoded message with the
> `VTABLE_DEFAULT_ERROR` constant, but I assume you did it so that we
> can just remove the constant later when everyone is migrated.
Correct.
>
> By the way, did you consider allowing `unused_variables`? It could be
> nice to not have to use `_` in the signatures.
I didn't because existing users are all _ prefixed already. But it does make
sense to add that to avoid having to prefix them, just like mandatory methods.
Best,
Gary
prev parent reply other threads:[~2026-10-02 20:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
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
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DLUN3V3VNRZC.1PML6OCVBP2TN@garyguo.net \
--to=gary@garyguo.net \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=aliceryhl@google.com \
--cc=arnd@arndb.de \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=miguel.ojeda.sandonis@gmail.com \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--cc=work@onurozkan.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®