Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow structs without fields for a set #352

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading