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

From: Andreas Hindborg
Date: Fri Feb 28 2025 - 13:59:09 EST


"Alice Ryhl" <aliceryhl@xxxxxxxxxx> 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@xxxxxxxxxx>

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


Best regards,
Andreas Hindborg