rust-lang / rust-lang/rust-clippy
Lint macro definitions that don't allow trailing commas
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
You know how every few weeks I drop by this repo to suggest madly complex new lints? Yep, it's this time again.
Rustfmt and the formatting RFCs have come a long way, and seem to slowly settle on a stable formatting for most Rust code. From what I can gather, one of the guidelines is to use trailing commas in pretty much all multi-line lists (function arguments, but also where clauses, struct fields, and arrays). This is a guideline I like very much, as trailing commas help reduce the noise in diffs and allow one to easily reorder lines. (For the vec! macro, Rustfmt already does some reformatting, but for other macros it (rightly) does not change the tokens.)
I'd like to propose a lint that checks macro_rules! definitions, sees if there are repeated patterns and, if necessary, suggests to change the pattern to allow trailing commas.
I'm not entirely sure what the best way to do that is. An easy way to add trailing comma support is adding $(,)*, but that allows 0 to ∞ many trailing commas…
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
No file or test is named in the issue. Start by locating Clippy's existing macro_rules-related lint infrastructure and tests, then determine how repeated patterns and trailing-comma support should be recognized. Done means the lint identifies macro definitions that do not allow trailing commas and provides an appropriate suggestion without permitting unintended comma counts.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100