Re: [PATCH] rust: macros: update 'paste!' macro to accept string literals

From: Alice Ryhl
Date: Mon Oct 09 2023 - 06:02:44 EST


On Sun, Oct 8, 2023 at 11:51 AM Trevor Gross <tmgross@xxxxxxxxx> wrote:
> Enable combining identifiers with string literals in the 'paste!' macro.
> This allows combining user-specified strings with affixes to create
> namespaced identifiers.
>
> This sample code:
>
> macro_rules! m {
> ($name:lit) => {
> paste!(struct [<_some_ $name _struct_>];)
> }
> }
>
> m!("foo_bar");
>
> Would previously cause a compilation error. It will now generate:
>
> struct _some_foo_bar_struct_;
>
> Reported-by: FUJITA Tomonori <fujita.tomonori@xxxxxxxxx>
> Signed-off-by: Trevor Gross <tmgross@xxxxxxxxx>

Reviewed-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>