rust-clippy
rust-clippy copied to clipboard
redundant_pattern_matching failes to check whether contained value are used.
Summary
I found a example of redundant pattern matching in my code that wasn't picked up by clippy.
Lint Name
redundant_pattern_matching
Reproducer
I tried this code:
#[deny(clippy::redundant_pattern_matching)]
pub fn missing_warning(input: &str) -> bool {
// This is the match I expected 'redundant_pattern_matching' to warn me about.
let _result = match input.parse::<u32>() {
Ok(_) => input,
Err(_) => return false
};
true
}
I expected to see this happen:
Running cargo clippy should trigger an error and provide a suggestion in the form of:
pub fn expected_fix(input: &str) -> bool {
let _result = if input.parse::<u32>().is_ok() { input } else { return false }
}
Instead, this happened:
Running cargo clippy did not report any errors.
Version
rustc 1.76.0 (07dca489a 2024-02-04)
binary: rustc
commit-hash: 07dca489ac2d933c78d3c5158e3f43beefeb02e
commit-date: 2024-02-04
host: x86_64-pc-windows-msvc
release: 1.76.0
LLVM version: 17.0.6