rust-lang / rust-lang/rust-clippy
Lint suggestion: Mismatched macro repetition operator
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
What it does
In a macro_rules! definition, there are three different repetition operators that can be used: *, +, ?. Rust accepts the code even if the repetition operator in the macro matcher is different from the repetition operator in the macro transcriber. This lint would warn against such a mismatch.
Advantage
- Having mismatched repetition operators can be confusing, since the kind of repetition operator used in the macro transcriber is ignored, and therefore can be misleading.
- Mismatched repetition operators can be a sign of a bug, where the macro author intended to refer to a different "repetition group".
Drawbacks
No response
Example
macro_rules! my_macro {
($($i:ident)?) => {
$($i)*
}
}
Could be written as:
macro_rules! my_macro {
($($i:ident)?) => {
$($i)?
}
}
Comparison with existing lints
No response
Additional Context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue does not name implementation files or tests. Start by comparing the macro_rules! examples with Rust's repetition documentation and determine how Clippy should detect differing matcher and transcriber operators; done means the mismatch is warned about without warning for matching operators.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100