I am writing some code to emit a declarative macro, and as you know, a decl macro is an Ident followed by a bang !, followed by a Group of non-Rust tokens. I want to generate this macro via code, but if I write my_macro! to the TokenStream via the quote! macro, it treats my_macro as an Ident and inserts a space between that and the !, making my emitted code (valid as pointed in the comments). I would still prefer to omit the whitespace. Is there a workaround this as I can feel that this problem will creep up again when I am writing the body of the decl macro.
PS: I have tried writing and Ident::new("my_macro") and a Punct::new('!', Spacing::Joint) but that didn't help.
The easy way is to create a
syn::Macroand use its ToTokens implementation.