diff --git a/serde_derive/src/de.rs b/serde_derive/src/de.rs index fb9991fbe9..6171600ff6 100644 --- a/serde_derive/src/de.rs +++ b/serde_derive/src/de.rs @@ -2556,17 +2556,6 @@ fn deserialize_map( }) }; - let match_keys = quote! { - let mut __seed = #field_seed; - while let _serde::__private::Some(__key) = _serde::de::MapAccess::next_key_seed(&mut __map, &mut __seed)? { - match __key { - #(#value_arms)* - #field_enum::Field(_) => unreachable!(), - #ignored_arm - } - } - }; - let extract_values = fields_names .iter() .filter(|&&(field, _)| !field.attrs.skip_deserializing() && !field.attrs.flatten()) @@ -2657,7 +2646,14 @@ fn deserialize_map( #let_collect - #match_keys + let mut __seed = #field_seed; + while let _serde::__private::Some(__key) = _serde::de::MapAccess::next_key_seed(&mut __map, &mut __seed)? { + match __key { + #(#value_arms)* + #field_enum::Field(_) => unreachable!(), + #ignored_arm + } + } #let_default @@ -2747,17 +2743,6 @@ fn deserialize_map_in_place( }) }; - let match_keys = quote! { - let mut __seed = #field_seed; - while let _serde::__private::Some(__key) = _serde::de::MapAccess::next_key_seed(&mut __map, &mut __seed)? { - match __key { - #(#value_arms_from)* - #field_enum::Field(_) => unreachable!(), - #ignored_arm - } - } - }; - let check_flags = fields_names .iter() .filter(|&&(field, _)| !field.attrs.skip_deserializing()) @@ -2806,7 +2791,14 @@ fn deserialize_map_in_place( quote_block! { #(#let_flags)* - #match_keys + let mut __seed = #field_seed; + while let _serde::__private::Some(__key) = _serde::de::MapAccess::next_key_seed(&mut __map, &mut __seed)? { + match __key { + #(#value_arms_from)* + #field_enum::Field(_) => unreachable!(), + #ignored_arm + } + } #let_default