Only allow #[serde(default)]` on structs

This commit is contained in:
Thomas de Zeeuw committed 2017-02-21 00:15:00 +01:00
1 parent 9444db5f19
commit 7bee779514
3 files changed
+24 -1

No files matched your search

+8 -1
View File
@@ -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")]`