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

needless nested match #13773

Open
owenthewizard opened this issue Dec 3, 2024 · 1 comment · May be fixed by #13798
Open

needless nested match #13773

owenthewizard opened this issue Dec 3, 2024 · 1 comment · May be fixed by #13798
Labels
A-lint Area: New lints

Comments

@owenthewizard
Copy link

What it does

Warn on a nested match that can be merged.

Advantage

  • Clarity
  • Concise

Drawbacks

  • Could be less readable in non-trivial cases (not Option/Result).

Example

match token {
    Ok(token) => match token {
        Token::A | Token::B => { ... }
    }
    Err(err) => {}
}

Could be written as:

match token {
    Ok(Token::A | Token::B) => { ... }
    Err(err) => {}
}
@owenthewizard owenthewizard added the A-lint Area: New lints label Dec 3, 2024
@y21
Copy link
Member

y21 commented Dec 3, 2024

This sounds like what the collapsible_match lint looks for. That lint should probably be extended to catch this

@lapla-cogito lapla-cogito linked a pull request Dec 9, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants