From 3a3e6bf103aec362e6be9c527ce0e8498aa981d0 Mon Sep 17 00:00:00 2001 From: Mingun Date: Mon, 1 May 2023 01:14:58 +0500 Subject: [PATCH] Reorder variables to match order in final quote! --- serde_derive/src/de.rs | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/serde_derive/src/de.rs b/serde_derive/src/de.rs index cad79d30..162ae5e1 100644 --- a/serde_derive/src/de.rs +++ b/serde_derive/src/de.rs @@ -1171,13 +1171,21 @@ fn deserialize_struct_in_place( }) .collect(); - let field_visitor = deserialize_generated_identifier(&field_names_idents, cattrs, false, None); + let field_visitor = Stmts(deserialize_generated_identifier( + &field_names_idents, + cattrs, + false, + None, + )); + let all_skipped = fields.iter().all(|field| field.attrs.skip_deserializing()); + let visitor_var = if all_skipped { + quote!(_) + } else { + quote!(mut __seq) + }; let visit_seq = Stmts(deserialize_seq_in_place(params, fields, cattrs, expecting)); - let visit_map = deserialize_map_in_place(params, fields, cattrs); - - let field_visitor = Stmts(field_visitor); - let visit_map = Stmts(visit_map); + let visit_map = Stmts(deserialize_map_in_place(params, fields, cattrs)); let field_names = field_names_idents.iter().map(|(name, _, _)| name); let visitor_expr = quote! { @@ -1201,13 +1209,6 @@ fn deserialize_struct_in_place( } }; - let all_skipped = fields.iter().all(|field| field.attrs.skip_deserializing()); - let visitor_var = if all_skipped { - quote!(_) - } else { - quote!(mut __seq) - }; - let in_place_impl_generics = de_impl_generics.in_place(); let in_place_ty_generics = de_ty_generics.in_place(); let place_life = place_lifetime();