Open workingjubilee opened 7 months ago
Why don't you suggest to put quote!()
behind a feature flag of the quote
crate instead?
Hmm. To do that is either
quote
crateWhile I have had many thoughts about what would be better designs for the macro crates that David Tolnay maintains, and have considered posing them to him, that one seemed obviously untenable to suggest.
Seems like one might as well git grep "quote\! {"
or am I missing something?
"this clippy lint might as well be a bash oneliner" so not sure if its worth coding out. Iirc there also was a stance of not adding too many crate-specific lints at some point as far as I recall.
What it does
Lints against
quote::quote!
and recommendsquote::quote_spanned!
Advantage
Proc macros have essentially zero diagnostics unless they provide such themselves, and tracking Spans, feeding them forward, is a bare-minimum requirement for this. There is a massive number of crates in the ecosystem which use
quote
but have absolutely execrable diagnostics because they don't bother. Becausequote!
is easy to use but doesn't ask for a span, they probably don't even realize they need to do this. Proc macros are somewhat of a "dark art" of Rust and people often regard them as unapproachable, and this is probably part of why.Drawbacks
In some cases, there is genuinely no useful span, so you would just be calling
Span::call_site()
and feeding it in to satisfy the lint. Oh well.Example
Could be written as: