Skip to content

Serde: duplicate field in base struct and flattened struct #5768

Open
@RCasatta

Description

@RCasatta

What it does

Warns when a conflicting field name is present in both a struct and in a flattened field.

I open an issue in the serde repo serde-rs/serde#1820 and they suggested me to open it here

Categories (optional)

  • Kind: Not sure

Avoid uncertainty about which field will be the one becoming serialized

Example

pub struct Base {
    #[serde(flatten)]
    pub flattened: Option<Flattened>,
    pub name: String,
}

pub struct Flattened {
    pub name: String,
}

Could issue a clippy warning suggesting to delete one of the fields named name or rename.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintArea: New lintsE-hardCall for participation: This a hard problem and requires more experience or effort to work on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions