Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always delegate returning errors to the Visitor from Content[Ref]Deserializer #2811

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Remove confusing call to deserialize_untagged_variant in deserialize_…
…internally_tagged_variant

deserialize_untagged_variant in that place is called when deserialzie_with attribute is set.
In that case it performs special actions that is better to use explicitly in deserialize_untagged_variant
for readability
  • Loading branch information
Mingun committed Dec 27, 2024
commit e66a40bb27b4989c3654ca851fb236e9e945acdc
7 changes: 5 additions & 2 deletions serde_derive/src/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1857,8 +1857,11 @@ fn deserialize_internally_tagged_variant(
cattrs: &attr::Container,
deserializer: TokenStream,
) -> Fragment {
if variant.attrs.deserialize_with().is_some() {
return deserialize_untagged_variant(params, variant, cattrs, deserializer);
if let Some(path) = variant.attrs.deserialize_with() {
let unwrap_fn = unwrap_to_variant_closure(params, variant, false);
return quote_block! {
_serde::__private::Result::map(#path(#deserializer), #unwrap_fn)
};
}

let variant_ident = &variant.ident;
Expand Down