Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ambigous_pattern lint #2378

Open
SoniEx2 opened this issue Jan 18, 2018 · 0 comments
Open

ambigous_pattern lint #2378

SoniEx2 opened this issue Jan 18, 2018 · 0 comments
Labels
A-lint Area: New lints C-an-interesting-project Category: Interesting projects, that usually are more involved design/code wise. E-medium Call for participation: Medium difficulty level problem and requires some initial experience. L-guidelines Lint: Related to the Rust API Guidelines T-middle Type: Probably requires verifiying types

Comments

@SoniEx2
Copy link

SoniEx2 commented Jan 18, 2018

Ref: rust-lang/rfcs#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*/},
}
@oli-obk oli-obk added E-medium Call for participation: Medium difficulty level problem and requires some initial experience. T-middle Type: Probably requires verifiying types A-lint Area: New lints C-an-interesting-project Category: Interesting projects, that usually are more involved design/code wise. L-guidelines Lint: Related to the Rust API Guidelines labels Jan 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints C-an-interesting-project Category: Interesting projects, that usually are more involved design/code wise. E-medium Call for participation: Medium difficulty level problem and requires some initial experience. L-guidelines Lint: Related to the Rust API Guidelines T-middle Type: Probably requires verifiying types
Projects
None yet
Development

No branches or pull requests

2 participants