Re: [PATCH v2 2/5] rust: macros: support additional tokens in quote!

Andreas Hindborg
2025-02-28T18:58:47Z

"Alice Ryhl" <aliceryhl@google.com> writes:

> This gives the quote! macro support for the following additional tokens:
>
> * The = token.
> * The _ token.
> * Using #my_var with variables of type Ident.
>
> Additionally, some type annotations are added to allow cases where
> groups are empty. For example, quote! does support () in the input, but
> only when it is *not* empty. When it is empty, the compiler cannot infer
> the item type of `tokens`.
>
> These additional quote! features are used by a new proc macro that
> generates code looking like this:
>
> const _: () = {
> if true {
> ::kernel::bindings::#name
> } else {
> #name
> };
> };
>
> where #name has type Ident.
>
> Signed-off-by: Alice Ryhl <aliceryhl@google.com>

Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org>

Best regards,
Andreas Hindborg