Closed
Description
I have a macro like this:
#[macro_export]
macro_rules! define_proc_macros {
(
$(
$( #[$attr:meta] )*
pub fn $proc_macro_name: ident ($input: ident : &str) -> String
$body: block
)+
) => {
$(
$( #[$attr] )*
#[proc_macro_derive($proc_macro_name)]
pub fn $proc_macro_name(derive_input: ::proc_macro::TokenStream)
-> ::proc_macro::TokenStream {
let $input = derive_input.to_string();
let $input = $crate::_extract_input(&$input);
$body.parse().unwrap()
}
)+
}
}
pub fn _extract_input(derive_input: &str) -> &str {
// …
}
When I use it, I get the warning in the title twice for every generated functions. When I move things into one crate to avoid "note: this error originates in a macro outside of the current crate", the span of the warning is on $proc_macro_name
in #[proc_macro_derive($proc_macro_name)]
.
Steps to reproduce: runCARGO_INCREMENTAL=1 cargo +nightly build -p cssparser-macros
in https://github.com/servo/rust-cssparser/.
I don’t understand this warning and what I can do about it. What does quasi-quoting mean in this context? How bad is the inefficiency really? Is it possible to fix it while keeping this macro’s flexibility?
CC @michaelwoerister and @nikomatsakis for #37787 that added this warning.