mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-25 20:57:55 +00:00
Only allow #[serde(default)]` on structs
This commit is contained in:
@@ -167,7 +167,14 @@ impl Item {
|
||||
|
||||
// Parse `#[serde(default)]`
|
||||
MetaItem(Word(ref name)) if name == "default" => {
|
||||
default.set_true();
|
||||
match item.body {
|
||||
syn::Body::Struct(_) => {
|
||||
default.set_true();
|
||||
}
|
||||
_ => {
|
||||
cx.error("#[serde(default)] can only be used on structs")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Parse `#[serde(bound="D: Serialize")]`
|
||||
|
||||
Reference in New Issue
Block a user