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

New Lint: Explicit ranges with p0 | ... | p_n => range pat #4931

Closed
Centril opened this issue Dec 21, 2019 · 2 comments · Fixed by #10968
Closed

New Lint: Explicit ranges with p0 | ... | p_n => range pat #4931

Centril opened this issue Dec 21, 2019 · 2 comments · Fixed by #10968
Labels
A-lint Area: New lints L-complexity Lint: Belongs in the complexity lint group L-suggestion Lint: Improving, adding or fixing lint suggestions

Comments

@Centril
Copy link
Contributor

Centril commented Dec 21, 2019

Category: Complexity

Consider:

match x {
    1 | 2 | 4 | 3 => 0,
     _ => 1,
}

Ostensibly the or-pattern would be more clearly written as 1..=4.

I would suggest making the analysis on HAIR.

cc @oli-obk cc rust-lang/rust#67488

@Centril Centril changed the title New Lint: Explicitly written ranges with p0 | ... | p_n => range pat New Lint: Explicit ranges with p0 | ... | p_n => range pat Dec 21, 2019
@flip1995 flip1995 added L-complexity Lint: Belongs in the complexity lint group A-lint Area: New lints L-suggestion Lint: Improving, adding or fixing lint suggestions labels Dec 22, 2019
@ghost
Copy link

ghost commented Dec 25, 2019

I thought HAIR was something used internally by the MIR crates. How do you access it from a lint?

@Centril
Copy link
Contributor Author

Centril commented Dec 26, 2019

Not sure; HIR probably works as well but is less desugared.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints L-complexity Lint: Belongs in the complexity lint group L-suggestion Lint: Improving, adding or fixing lint suggestions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants