Re: [PATCH v2] rust: macros: support `#[cfg]` properly in `#[vtable]` macro.
From: Benno Lossin
Date: Sat Jan 17 2026 - 15:09:51 EST
On Tue Jan 13, 2026 at 6:05 PM CET, Gary Guo wrote:
> From: Gary Guo <gary@xxxxxxxxxxx>
>
> Currently, we generate `HAS_` constants as long as the definition exists in
> the source, regardless if it is cfg-ed out or not.
>
> Currently, uses of `#[cfg]` present in both trait and impl, so it is not a
> problem; however if only the impl side uses `#[cfg]` then `HAS_` constants
> will incorrectly be true while it shouldnt't.
>
> With `syn` support, we can now implement `#[cfg]` handling properly by
> propagating the `#[cfg]` attributes to the constants.
>
> Signed-off-by: Gary Guo <gary@xxxxxxxxxxx>
Reviewed-by: Benno Lossin <lossin@xxxxxxxxxx>
Cheers,
Benno
> ---
> rust/macros/helpers.rs | 6 ++++++
> rust/macros/vtable.rs | 13 ++++---------
> 2 files changed, 10 insertions(+), 9 deletions(-)