@@ -281,13 +281,9 @@ fn deserialize_body(cont: &Container, params: &Parameters) -> Fragment {
281
281
} else if let attr:: Identifier :: No = cont. attrs . identifier ( ) {
282
282
match & cont. data {
283
283
Data :: Enum ( variants) => deserialize_enum ( params, variants, & cont. attrs ) ,
284
- Data :: Struct ( Style :: Struct , fields) => deserialize_struct (
285
- params,
286
- fields,
287
- & cont. attrs ,
288
- cont. attrs . has_flatten ( ) ,
289
- StructForm :: Struct ,
290
- ) ,
284
+ Data :: Struct ( Style :: Struct , fields) => {
285
+ deserialize_struct ( params, fields, & cont. attrs , StructForm :: Struct )
286
+ }
291
287
Data :: Struct ( Style :: Tuple , fields) | Data :: Struct ( Style :: Newtype , fields) => {
292
288
deserialize_tuple (
293
289
params,
@@ -927,7 +923,6 @@ fn deserialize_struct(
927
923
params : & Parameters ,
928
924
fields : & [ Field ] ,
929
925
cattrs : & attr:: Container ,
930
- has_flatten : bool ,
931
926
form : StructForm ,
932
927
) -> Fragment {
933
928
let this_type = & params. this_type ;
@@ -976,6 +971,10 @@ fn deserialize_struct(
976
971
)
977
972
} )
978
973
. collect ( ) ;
974
+
975
+ let has_flatten = fields
976
+ . iter ( )
977
+ . any ( |field| field. attrs . flatten ( ) && !field. attrs . skip_deserializing ( ) ) ;
979
978
let field_visitor = deserialize_field_identifier ( & field_names_idents, cattrs, has_flatten) ;
980
979
981
980
// untagged struct variants do not get a visit_seq method. The same applies to
@@ -1838,7 +1837,6 @@ fn deserialize_externally_tagged_variant(
1838
1837
params,
1839
1838
& variant. fields ,
1840
1839
cattrs,
1841
- variant. attrs . has_flatten ( ) ,
1842
1840
StructForm :: ExternallyTagged ( variant_ident) ,
1843
1841
) ,
1844
1842
}
@@ -1882,7 +1880,6 @@ fn deserialize_internally_tagged_variant(
1882
1880
params,
1883
1881
& variant. fields ,
1884
1882
cattrs,
1885
- variant. attrs . has_flatten ( ) ,
1886
1883
StructForm :: InternallyTagged ( variant_ident, deserializer) ,
1887
1884
) ,
1888
1885
Style :: Tuple => unreachable ! ( "checked in serde_derive_internals" ) ,
@@ -1940,7 +1937,6 @@ fn deserialize_untagged_variant(
1940
1937
params,
1941
1938
& variant. fields ,
1942
1939
cattrs,
1943
- variant. attrs . has_flatten ( ) ,
1944
1940
StructForm :: Untagged ( variant_ident, deserializer) ,
1945
1941
) ,
1946
1942
}
0 commit comments