-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Code
Example repo that demonstrates the problem https://github.com/schneems/serde-deserializer-wrapper-demo
Current output
error[E0308]: mismatched types
--> src/main.rs:361:33
|
46 | impl<'de, T, E> serde::de::Deserializer<'de> for ResultDeWrapper<'de, T, E>
| - expected this type parameter
|
356 | fn deserialize_ignored_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
| ----------------------------- expected `Result<<V as Visitor<'de>>::Value, E>` because of return type
|
361 | Ok(deserializer) => deserializer.deserialize_ignored_any(visitor),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Result<<V as Visitor<'_>>::Value, E>`, found `Result<<V as Visitor<'_>>::Value, ...>`
= note: expected enum `Result<_, E>`
found enum `Result<_, <T as _serde::Deserializer<'de>>::Error>`
help: consider further restricting this bound
|
48 | T: serde::de::Deserializer<'de><Error = E>,
| +++++++++++
Desired output
error[E0308]: mismatched types
--> src/main.rs:361:33
|
46 | impl<'de, T, E> serde::de::Deserializer<'de> for ResultDeWrapper<'de, T, E>
| - expected this type parameter
|
356 | fn deserialize_ignored_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
| ----------------------------- expected `Result<<V as Visitor<'de>>::Value, E>` because of return type
|
361 | Ok(deserializer) => deserializer.deserialize_ignored_any(visitor),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Result<<V as Visitor<'_>>::Value, E>`, found `Result<<V as Visitor<'_>>::Value, ...>`
= note: expected enum `Result<_, E>`
found enum `Result<_, <T as _serde::Deserializer<'de>>::Error>`
help: consider further restricting this bound
|
48 | T: serde::de::Deserializer<'de, Error = E>,
| +++++++++++
Rationale and extra context
The suggested change is a syntax error. The goal of the bounds is to convince Rust that the E
is the same type as the T impl serde::de::Deserializer::Error
.
Other cases
Rust Version
$ rustc --version --verbose
rustc 1.89.0 (29483883e 2025-08-04)
binary: rustc
commit-hash: 29483883eed69d5fb4db01964cdf2af4d86e9cb2
commit-date: 2025-08-04
host: aarch64-apple-darwin
release: 1.89.0
LLVM version: 20.1.7
Anything else?
No response
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.