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

Identical match arm not detected #11223

Closed
vanillajonathan opened this issue Jul 24, 2023 · 2 comments · Fixed by #12059
Closed

Identical match arm not detected #11223

vanillajonathan opened this issue Jul 24, 2023 · 2 comments · Fixed by #12059
Assignees
Labels
C-bug Category: Clippy is not doing the correct thing good-first-issue These issues are a good way to get started with Clippy I-false-negative Issue: The lint should have been triggered on code, but wasn't

Comments

@vanillajonathan
Copy link

vanillajonathan commented Jul 24, 2023

Summary

Clippy doesn't catch that match arms are identical when using if on Some.

Lint Name

match_same_arms

Reproducer

I tried this code:

match Some(3) {
    Some(v) if v == 3 => true,
    Some(v) if v == 3 => true,
    _ => false,

I expected to see this happen: Clippy would catch that the arms are identical.

Instead, this happened: Nothing. Clippy didn't catch on.

Version

rustc 1.71.0 (8ede3aae2 2023-07-12)
binary: rustc
commit-hash: 8ede3aae28fe6e4d52b38157d7bfe0d3bceef225
commit-date: 2023-07-12
host: x86_64-unknown-linux-gnu
release: 1.71.0
LLVM version: 16.0.5
@vanillajonathan vanillajonathan added C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't labels Jul 24, 2023
@xFrednet
Copy link
Member

It's likely, that the lint assumes, that the guards are different. This should be fixable by checking the if expressions as well.

@rustbot label +good-first-issue

@rustbot rustbot added the good-first-issue These issues are a good way to get started with Clippy label Dec 29, 2023
@roife
Copy link
Member

roife commented Dec 30, 2023

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing good-first-issue These issues are a good way to get started with Clippy I-false-negative Issue: The lint should have been triggered on code, but wasn't
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants