Closed as not planned
Description
What it does
This would lint against use of $smth
in the expansion part of a macro_rules!
if smth
is not a capture. While such a pattern could be used in a recursive macro, it is being phased out, so in practice it is likely an typo, especially if the name of smth
is close to an actual capture.
See dzamlo/rust-bitfield#40 for the case that prompted this lint suggestion.
Advantage
- Detect potential bugs in macros.
Macros are hard to debug and have very little compile-time validity checks. Complex recursive macros are very complex, and can have many rules. Any tool to improve that is good.
Drawbacks
There is a possibility of false positives
Example
macro_rules! testing {
($testing:ty) => {$testin}
}
Will never be usable because testin
is not a capture (notice the missing g
) is not a capture.
it should instead be written as:
macro_rules! testing {
($testing:ty) => {$testing}
}