Merged
Conversation
`let...else` provides a standard construct for this same pattern that people can easily recognize (and is IMO much less confusing). It's also more compact. This fixes the `manual_let_else` clippy lint.
`match` arms with identical arm bodies are confusing to the reader because they hide the intent to the reader. This fixes the `match_same_arms` clippy lint.
`if let..else` statements nest less than `match` statements with two arms and are therefore more readable. This fixes the `single_match_else` clippy lint.
Pattern matching that are really just checking for equality are more idiomatically described using the `matches!` macro instead of `if let` statements. `if let` statements use Yoda notation [1] which increase cognitive load while reading the code. This fixes the `equatable_if_let` clippy lint. [1]: https://en.wikipedia.org/wiki/Yoda_conditions
Seems to not have been found by clippy on my machine. This fixes the `manual_let_else` clippy lint. See-also: 4332e94
Forgot to run cargo-fmt during the previous commits.
jplatte
reviewed
Jul 9, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
This PR is part of the broader PR #3394 (Activate more lints)
There are many different ways to express the same pattern matching and equality checking. This PR standardises those two things using clippy lints, and also makes the code more readable.
Solution
This PR adds 4 new lints to
Cargo.toml:manual_let_elsematch_same_armssingle_match_elseequatable_if_let