Skip to content

warning: Quasi-quoting might make incremental compilation very inefficient: NtIdent(..) #40946

Closed
@SimonSapin

Description

@SimonSapin

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.

Metadata

Metadata

Assignees

Labels

A-incr-compArea: Incremental compilationC-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions