Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Mingun opened this issue Aug 10, 2023 · 0 comments · May be fixed by #2567
Open

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

Mingun opened this issue Aug 10, 2023 · 0 comments · May be fixed by #2567

Comments

@Mingun
Copy link
Contributor

Mingun commented Aug 10, 2023

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

Mingun added a commit to Mingun/serde that referenced this issue Aug 10, 2023
failures (1):
    regression::issue2565::simple_variant
@Mingun Mingun linked a pull request Aug 10, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants