We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
proc_macro::quote!
1 parent 8c71c64 commit d7f1e02Copy full SHA for d7f1e02
proc_macro/src/quote.rs
@@ -112,8 +112,14 @@ pub fn quote(stream: TokenStream) -> TokenStream {
112
)), &mut ts);)
113
}
114
TokenTree::Ident(tt) => {
115
- minimal_quote!(crate::ToTokens::to_tokens(&crate::TokenTree::Ident(crate::Ident::new(
116
- (@ TokenTree::from(Literal::string(&tt.to_string()))),
+ let literal = tt.to_string();
+ let (literal, ctor) = if let Some(stripped) = literal.strip_prefix("r#") {
117
+ (stripped, minimal_quote!(crate::Ident::new_raw))
118
+ } else {
119
+ (literal.as_str(), minimal_quote!(crate::Ident::new))
120
+ };
121
+ minimal_quote!(crate::ToTokens::to_tokens(&crate::TokenTree::Ident((@ ctor)(
122
+ (@ TokenTree::from(Literal::string(literal))),
123
(@ quote_span(proc_macro_crate.clone(), tt.span())),
124
125
0 commit comments