mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-26 00:27:56 +00:00
Correctly calculate has_flatten attribute in all cases for deserialization
Consequence: `FlattenSkipDeserializing[DenyUnknown]` - does not collect data in Field, because do not read them anyway - gets `deserialize_in_place` method - gets ability to deserialize from sequence (visit_seq method) - uses `deserialize_struct` instead of `deserialize_map`
This commit is contained in:
@@ -85,7 +85,6 @@ impl<'a> Container<'a> {
|
||||
for field in &mut variant.fields {
|
||||
if field.attrs.flatten() {
|
||||
has_flatten = true;
|
||||
variant.attrs.mark_has_flatten();
|
||||
}
|
||||
field.attrs.rename_by_rules(
|
||||
variant
|
||||
|
||||
@@ -810,18 +810,6 @@ pub struct Variant {
|
||||
rename_all_rules: RenameAllRules,
|
||||
ser_bound: Option<Vec<syn::WherePredicate>>,
|
||||
de_bound: Option<Vec<syn::WherePredicate>>,
|
||||
/// True if variant is a struct variant which contains a field with
|
||||
/// `#[serde(flatten)]`.
|
||||
///
|
||||
/// ```ignore
|
||||
/// enum Enum {
|
||||
/// Variant {
|
||||
/// #[serde(flatten)]
|
||||
/// some_field: (),
|
||||
/// },
|
||||
/// }
|
||||
/// ```
|
||||
has_flatten: bool,
|
||||
skip_deserializing: bool,
|
||||
skip_serializing: bool,
|
||||
other: bool,
|
||||
@@ -991,7 +979,6 @@ impl Variant {
|
||||
},
|
||||
ser_bound: ser_bound.get(),
|
||||
de_bound: de_bound.get(),
|
||||
has_flatten: false,
|
||||
skip_deserializing: skip_deserializing.get(),
|
||||
skip_serializing: skip_serializing.get(),
|
||||
other: other.get(),
|
||||
@@ -1034,14 +1021,6 @@ impl Variant {
|
||||
self.de_bound.as_ref().map(|vec| &vec[..])
|
||||
}
|
||||
|
||||
pub fn has_flatten(&self) -> bool {
|
||||
self.has_flatten
|
||||
}
|
||||
|
||||
pub fn mark_has_flatten(&mut self) {
|
||||
self.has_flatten = true;
|
||||
}
|
||||
|
||||
pub fn skip_deserializing(&self) -> bool {
|
||||
self.skip_deserializing
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user