Lint explanation
It would be nice to lint Serde macros for unnecessary duplication.
For example:
- Specifying
default on an Option (Option is automatically default)
rename = "SomeThing" that matches the rename_all = "PascalCase" on the struct
- Suggest adding or removing
rename_all = "x" if that would result in less rename = "y" lines
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.
Lint explanation
It would be nice to lint Serde macros for unnecessary duplication.
For example:
defaulton anOption(Optionis automaticallydefault)rename = "SomeThing"that matches therename_all = "PascalCase"on the structrename_all = "x"if that would result in lessrename = "y"linesExample code
Notes
The output/expansion of the macro is not relevent for these lints.