Feature request: proc_macro with content as string
Rust Internals [Unofficial]
March 6, 2026
I wonder if Rust could eventually allow something like #[proc_macro_string] or #[proc_macro_block]. White space, en dash and other things makes things harder than needed when implementing a macro, at the moment. The idea is to take take the block as string and pass it to the macro.
Example:
#[proc_macro_block]
pub fn html(input: &str) -> TokenStream {
// process input block
}
Usage:
let content = html! {
<h1>The string to process</h1>
};
I can work on this. Would the change be accepted?
Discussion in the ATmosphere