single_match
shouldn't warn when matching on an explicit error type
#13371
Labels
C-bug
Category: Clippy is not doing the correct thing
I-false-positive
Issue: The lint was triggered on code it shouldn't have
Summary
In the following code, I think the clippy suggestion is worse than the original code. The original code is explicitly matching on the error "NotFoundError". If the error return type of
foo
were to change in the future (for example to become an enum with multiple error variants, or to become something like "NotAuthenticatedError" instead), we'd want this match statement to fail to build so that we could update it for the new error type and make sure we're handling it correctly. The clippy suggestion wants us to remove the error matching completely.I think it would be nicer if this lint only triggered when the error type is omitted completely, for example
Err(_) => {}
.Lint Name
single_match
Reproducer
I tried this code:
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=421e3fe89d0da5e2685c435d43246689
I saw this happen:
I expected to see this happen:
No warning.
Version
Additional Labels
No response
The text was updated successfully, but these errors were encountered: