rust-lang / rust-lang/rust-clippy
ambigous_pattern lint
Open
Nobody has claimed this yet.
A-lint
C-an-interesting-project
E-medium
L-guidelines
T-middle
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Ref: https://github.com/rust-lang/rfcs/issues/2272
I would like an ambiguous_pattern lint that either:
- requires the pattern to have
:: - requires the pattern to have
@
Those 2 requirements make it easy to avoid ambiguous patterns, for example:
match x {
C => {/*is this C a binding, or did you forget to import a constant?*/},
x => {/*is this x a lowercase constant or did you mean to make a binding?*/},
}
Instead, write it as:
match x {
m::C => {/*got constant C*/},
x @ _ => {/*got unknown*/},
}
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 names no implementation files or tests. Start by reviewing Clippy's existing pattern-lint entry points and the referenced Rust RFC issue, then determine how the proposed lint should distinguish qualified constants from bindings. Done means enforcing either :: or @ for the ambiguous patterns shown in the examples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers, devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 30/100