Skip to content

Proc macro rename attribute ignores trailing content #2242

Closed
@dnaka91

Description

@dnaka91

I just had an interesting bug where I made a spelling error for the rename attribute. When I discovered it, I thought the proc macro could probably catch this.

What I did by accident was:

#[derive(Deserialize)]
struct SomeStruct {
    #[serde(rename = ""value)] // This should have been `rename = "value"`
    pub a: i32
} 

The second " went in front of the rename value, instead of behind. Apparently, the proc macro accepts this input and only takes "", ignoring the value. If there is a space between it (like #[serde(rename = "" value)]), it'll fail properly, telling about the unknown attribute value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions