Open
Description
Code
use std::io::ErrorKind;
use std::borrow::Cow;
fn f(x: Result<i32, Vec<ErrorKind>>) -> bool {
matches!(x, Err([ErrorKind::NotFound]))
}
Current output
error[E0529]: expected an array or slice, found `Vec<ErrorKind>`
--> src/lib.rs:5:21
|
5 | matches!(x, Err([ErrorKind::NotFound]))
| ^^^^^^^^^^^^^^^^^^^^^ pattern cannot match with input type `Vec<ErrorKind>`
|
help: consider using `as_deref` here
|
5 | matches!(x.as_deref(), Err([ErrorKind::NotFound]))
| +++++++++++
Desired output
no suggestion to use as_deref
Rationale and extra context
as_deref
doesn't change the meaning of the code.- When applied, rustc will suggest to apply it again, which is absurd and confusing.
Other cases
matches!(x.as_deref().as_deref().as_deref(), Err([ErrorKind::NotFound]))
will suggest
help: consider using `as_deref` here
|
5 | matches!(x.as_deref().as_deref().as_deref().as_deref(), Err([ErrorKind::NotFound]))
| +++++++++++
Rust Version
rustc 1.81.0 (eeb90cda1 2024-09-04)
binary: rustc
commit-hash: eeb90cda1969383f56a2637cbd3037bdf598841c
commit-date: 2024-09-04
host: x86_64-unknown-linux-gnu
release: 1.81.0
LLVM version: 18.1.7
Anything else?
No response