Skip to content

#[serde(flatten)] in struct variants errously propagated to all variants from one variant #2565

@Mingun

Description

@Mingun

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

has_flatten: bool,

For enums has_flatten should be bound to the variant, not to the enum

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions