rust-lang / rust-lang/rust-clippy
match_like_matches_macro does not lint on T-F-T-style matches
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Summary
The middle detection of match_like_matches_macro could be more eager.
Below code is not linted because the lint currently requires the first and middle arms to return the same boolean value.
Here, the middle arm returns false while the first and last arms return true.
We can do better 😉
Lint Name
match_like_matches_macro
Reproducer
I tried this code:
#[warn(match_like_matches_macro)]
fn foo(){
match match_type {
MatchType::A(_str1) => true, // this bool != next one
MatchType::B(_str1, _str2) => false,
MatchType::C => true,
}
}
I expected to see this suggestion happen:
#[warn(match_like_matches_macro)]
fn foo(){
matches!(match_type(MatchType::A(_) | MatchType::C)
}
Instead, this happened:
no lint
Noticed in @wasd243's PR:
Version
rustc 1.98.0 (88d9e12ae 2026-08-18)
binary: rustc
commit-hash: 88d9e12ae178fab0fb5cc050a94da85685d449ea
commit-date: 2026-08-18
host: x86_64-unknown-linux-gnu
release: 1.98.0
LLVM version: 22.1.8
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the match_like_matches_macro lint and reproduce the T-F-T match from the issue. Compare the current first/middle-arm boolean requirement with the expected matches! suggestion, then add coverage for the example and verify that the lint emits the suggestion without false positives.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100