rust-lang / rust-lang/rust-clippy

ambigous_pattern lint

Open
#2,378 0 comments 0 reactions 0 assignees View on GitHub

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:

  1. requires the pattern to have ::
  2. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.