Skip to content

Commit

Permalink
Disallow structs without fields for a set (#352)
Browse files Browse the repository at this point in the history
  • Loading branch information
shahn authored Oct 23, 2024
1 parent 021211b commit 7bfd53b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion macros/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,8 @@ impl StringValue {
let string = if content.peek(syn::LitStr) {
content.parse::<syn::LitStr>()?.value()
} else if content.peek(syn::Ident) {
panic!("StringValue2: {:?}", content);
let path: syn::Path = content.parse()?;
path.require_ident()?.to_string()
} else {
panic!("StringValue Unsupported meta item: {:?}", content);
};
Expand Down
3 changes: 3 additions & 0 deletions macros/src/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ pub fn derive_struct_impl(
}
}
} else if config.set {
if container.fields.is_empty() {
panic!("`struct`s without any fields are not currently supported as `set`s.")
}
let field_names = container.fields.iter().map(|field| field.ident.clone());
let field_names2 = field_names.clone();
let required_field_names = container
Expand Down

0 comments on commit 7bfd53b

Please sign in to comment.