Repository navigation
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsD-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
Description
Code
use std::ffi::FromBytesWithNulError; // or any other enum
fn f(err: Result<(), Vec<FromBytesWithNulError>>) {
assert!(matches!(err, Err([FromBytesWithNulError::InteriorNul{..}])));
}Current output
error[E0529]: expected an array or slice, found `Vec<FromBytesWithNulError>`
--> src/lib.rs:4:31
|
4 | assert!(matches!(err, Err([FromBytesWithNulError::InteriorNul{..}])));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern cannot match with input type `Vec<FromBytesWithNulError>`
|
help: consider using `as_deref` here
|
4 | assert!(matches!(err.as_deref(), Err([FromBytesWithNulError::InteriorNul{..}])));
| +++++++++++Desired output
error[E0529]: expected an array or slice, found `Vec<FromBytesWithNulError>`
--> src/lib.rs:4:31
|
4 | assert!(matches!(err, Err([FromBytesWithNulError::InteriorNul{..}])));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern cannot match with input type `Vec<FromBytesWithNulError>`Rationale and extra context
When applied, the code doesn't compile because () doesn't implement Deref:
error[E0599]: the method `as_deref` exists for enum `Result<(), Vec<FromBytesWithNulError>>`, but its trait bounds were not satisfied
--> src/lib.rs:4:26
|
4 | assert!(matches!(err.as_deref(), Err([FromBytesWithNulError::InteriorNul{..}])));
| ^^^^^^^^
|
= note: the following trait bounds were not satisfied:
`(): Deref`
Other cases
Rust Version
rustc 1.101.0-nightly (92b5b8c87 2026-10-29)
binary: rustc
commit-hash: 92b5b8c87c61b20adc9001b41baf587634a74734
commit-date: 2026-10-29
host: x86_64-unknown-linux-gnu
release: 1.101.0-nightly
LLVM version: 23.1.4Anything else?
No response
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsD-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
Activity
Rollup merge of rust-lang#165406 - lapla-cogito:issue_165365, r=diann…
Rollup merge of rust-lang#165406 - lapla-cogito:issue_165365, r=diann…
Rollup merge of rust-lang#165406 - lapla-cogito:issue_165365, r=diann…
Rollup merge of rust-lang#165406 - lapla-cogito:issue_165365, r=diann…
Rollup merge of rust-lang#165406 - lapla-cogito:issue_165365, r=diann…
Rollup merge of rust-lang#165406 - lapla-cogito:issue_165365, r=diann…
Unrolled build for #165406 in rollup 166046
Rollup merge of #165406 - lapla-cogito:issue_165365, r=dianne,adwinwhite
Rollup merge of #165406 - lapla-cogito:issue_165365, r=dianne,adwinwhite
Rollup merge of #165406 - lapla-cogito:issue_165365, r=dianne,adwinwhite