Re: [PATCH v2 03/11] rust: macros: convert `#[vtable]` macro to use `syn`
From: Benno Lossin
Date: Sun Jan 11 2026 - 12:04:03 EST
On Wed Jan 7, 2026 at 5:15 PM CET, Gary Guo wrote:
> From: Gary Guo <gary@xxxxxxxxxxx>
>
> `#[vtable]` is converted to use syn. This is more robust than the
> previous heuristic-based searching of defined methods and functions.
>
> When doing so, the trait and impl are split into two code paths as the
> types are distinct when parsed by `syn`.
>
> Signed-off-by: Gary Guo <gary@xxxxxxxxxxx>
Reviewed-by: Benno Lossin <lossin@xxxxxxxxxx>
> ---
> rust/macros/lib.rs | 9 ++-
> rust/macros/vtable.rs | 163 ++++++++++++++++++++++--------------------
> 2 files changed, 93 insertions(+), 79 deletions(-)
> + // Skip if it's declared already -- this can happen if `#[cfg]` is used to selectively
> + // define functions.
> + // FIXME: `#[cfg]` should be copied and propagated to the generated consts.
Do you mind creating an issue (probably difficulty medium) after this is
merged?
Cheers,
Benno
> + if consts.contains(&gen_const_name) {
> + continue;
> + }