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

Andreas Hindborg a.hindborg at kernel.org
Fri Feb 28 18:51:21 UTC 2025


"Alice Ryhl" <aliceryhl at 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 at google.com>

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


Best regards,
Andreas Hindborg




More information about the dri-devel mailing list