rust-marker / design

Apache License 2.0
15 stars 1 forks source link

`serde` macro lint #48

Open Kriskras99 opened 10 months ago

Kriskras99 commented 10 months ago

Lint explanation

It would be nice to lint Serde macros for unnecessary duplication. For example:

Example code

#[derive(Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct BadExample {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub default_option: Option<String>,
    #[serde(rename = "SomeThing")]
    pub some_thing: String,
}

#[derive(Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct GoodExample {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub default_option: Option<String>,
    pub some_thing: String,
}

Notes

The output/expansion of the macro is not relevent for these lints.

xFrednet commented 10 months ago

That's a cool suggestion, thank you for the issue! Marker is currently sadly lacking a representation for attributes (https://github.com/rust-marker/marker/issues/51), but I want to definitely support such lints.