External Publication
Visit Post

Feature request: proc_macro with content as string

Rust Internals [Unofficial] March 26, 2026
Source

I think I'd much rather have a my_macro!"foobar" syntax at that point, which could just desugar to a proc macro which has a single string literal in its token stream. Although at that point I'd think why not allow that syntax for other literals too, like my_macro!32 which is then hard to argue to be distinct from custom integer literals like 32my_macro.

On the implementation side passing which token the macro was called with (my_macro!(), my_macro![], my_macro!{}) using a macro metadata as a second parameter (like is being discussed with const derives right now) might be interesting as a more general addition.

Discussion in the ATmosphere

Loading comments...