serde
serde copied to clipboard
`#[serde(flatten)]` in struct variants errously propagated to all variants from one variant
In this enum __Field
structs for both variants generated like the variant contains flattened field, but that is true only for the second field:
#[derive(Deserialize)]
enum Enum<T> {
Simple {
a: i32,
},
Flatten {
#[serde(flatten)]
flatten: T,
},
}
This is happens because has_flatten
field in Container
struct becomes true
for enums if any variant contains #[serde(flatten)]
, but it makes little sense
https://github.com/serde-rs/serde/blob/05a5b7e3c6de502d45597cbc083f28bc1d4f4626/serde_derive/src/internals/attr.rs#L219
For enums has_flatten
should be bound to the variant, not to the enum