-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn'tIssue: The lint should have been triggered on code, but wasn't
Description
Summary
Uses of matches
macro with Result
or Option
in first argument and in the second argument is just here to check if the first argument is is_ok()
or is_some()
, do not lint. When I make cargo expand
on this:
matches!(Ok::<i32, i32>(10), Ok(_));
I have:
match Ok::<i32, i32>(10) {
Ok(_) => true,
_ => false,
};
Lint Name
redundant_pattern_match
Reproducer
I tried this code:
matches!(Ok::<i32, i32>(10), Ok(_));
I expected to see this happen:
Ok::<i32, i32>(10).is_ok()
Instead, this happened:
matches!(Ok::<i32, i32>(10), Ok(_));
Version
rustc 1.71.0-nightly (521f4dae1 2023-05-19)
binary: rustc
commit-hash: 521f4dae1bdf7fe9cf9436ecef9ee7c7442708bf
commit-date: 2023-05-19
host: x86_64-unknown-linux-gnu
release: 1.71.0-nightly
LLVM version: 16.0.4
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn'tIssue: The lint should have been triggered on code, but wasn't