-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
redundant_pattern_matching does not check for match with single arm #10726
Comments
Hey @disco07, thank you for the ticket :). Do you have a specific question related to it :) |
@xFrednet Can I work on this ? |
Yes, you're very welcome to! As a start, you can take a look at the lint code: https://github.com/rust-lang/rust-clippy/blob/master/clippy_lints/src/matches/redundant_pattern_match.rs And look at the AST structure of the code you want to detect. For this, I recommend using I guess that the lint ignores the match, as it expects the |
@rustbot claim |
1 similar comment
@rustbot claim |
redundant_pattern_matching This PR try to solve this issue #10726, but it enter in conflict with another test. Try to test this: ``` let _w = match x { Some(_) => true, _ => false, }; ``` this happen: ``` error: match expression looks like `matches!` macro --> $DIR/match_expr_like_matches_macro.rs:21:14 | LL | let _w = match x { | ______________^ LL | | Some(_) => true, LL | | _ => false, LL | | }; | |_____^ help: try this: `matches!(x, Some(_))` +error: redundant pattern matching, consider using `is_some()` + --> $DIR/match_expr_like_matches_macro.rs:21:14 + | +LL | let _w = match x { + | ______________^ +LL | | Some(_) => true, +LL | | _ => false, +LL | | }; + | |_____^ help: try this: `x.is_some()` + | + = note: `-D clippy::redundant-pattern-matching` implied by `-D warnings` + ``` I need some help to fix this. Thanks
redundant_pattern_matching This PR try to solve this issue #10726, but it enter in conflict with another test. changelog: none Try to test this: ``` let _w = match x { Some(_) => true, _ => false, }; ``` this happen: ``` error: match expression looks like `matches!` macro --> $DIR/match_expr_like_matches_macro.rs:21:14 | LL | let _w = match x { | ______________^ LL | | Some(_) => true, LL | | _ => false, LL | | }; | |_____^ help: try this: `matches!(x, Some(_))` +error: redundant pattern matching, consider using `is_some()` + --> $DIR/match_expr_like_matches_macro.rs:21:14 + | +LL | let _w = match x { + | ______________^ +LL | | Some(_) => true, +LL | | _ => false, +LL | | }; + | |_____^ help: try this: `x.is_some()` + | + = note: `-D clippy::redundant-pattern-matching` implied by `-D warnings` + ``` I need some help to fix this. Thanks
Summary
Use of match, matching
Result
orOption
; do not triggerclippy::redundant_pattern_matching
Reproducer
I tried this code:
I expected to see this happen:
Instead, this happened:
Version
Additional Labels
No response
The text was updated successfully, but these errors were encountered: