You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I filed a compiler bug on this too (rust-lang/rust#73082) but it would have been helpful to see suggested in the serde docs that when encountering a type annotations needed / cannot infer type for type parameter error when attempting to derive(Deserialize), the solution isn't always to add an annotation or to specify a Deserialize bound: in the case I ran into today (where the type parameter it was struggling with already implements DeserializeOwned), the solution is to annotate with #[serde(bound="")], disabling serde's attempt at inferring a bound entirely.
I think it's unlikely that adding information about this to the documentation would be a net benefit. In general, with more documentation of edge-cases, people read even less of the higher-value documentation, because the overall relevance is diluted. I think this specific issue comes up seldom enough that Stack Overflow can be sufficient coverage.
In your case, going by the rust-lang/rust issue, the problem was a consequence of rust-lang/rust#41617, which I am still hopeful will get fixed in rustc eventually.
I filed a compiler bug on this too (rust-lang/rust#73082) but it would have been helpful to see suggested in the serde docs that when encountering a
type annotations needed
/cannot infer type for type parameter
error when attempting toderive(Deserialize)
, the solution isn't always to add an annotation or to specify a Deserialize bound: in the case I ran into today (where the type parameter it was struggling with already implements DeserializeOwned), the solution is to annotate with#[serde(bound="")]
, disabling serde's attempt at inferring a bound entirely.I can't tell whether the right place to discuss this would be in https://serde.rs/container-attrs.html or https://serde.rs/attr-bound.html or some other place, the nearest hint I found on the matter was on stackoverflow (which I've added an extended answer for, in case anyone stumbles on it again: https://stackoverflow.com/a/62239787/1669902)
The text was updated successfully, but these errors were encountered: