fix: correctly parse top-level attribute

This commit is contained in:
naskya 2024-07-16 23:32:10 +09:00
parent 4ef0d0230f
commit 8b8953d071
Signed by: naskya
GPG key ID: 712D413B3A9FED5C

View file

@ -78,6 +78,7 @@ fn derive_impl(input: syn::DeriveInput) -> syn::Result<TokenStream> {
// * ident + punct // * ident + punct
// * ident + group + punct // * ident + group + punct
// * ident (the last one) // * ident (the last one)
// * ident + group (the last one)
let ident: syn::Ident = syn::parse2(token.into_token_stream())?; let ident: syn::Ident = syn::parse2(token.into_token_stream())?;
@ -104,6 +105,12 @@ fn derive_impl(input: syn::DeriveInput) -> syn::Result<TokenStream> {
}; };
extra_attrs.push(quote! { #[#ident #group] }); extra_attrs.push(quote! { #[#ident #group] });
// if the second item was group, we may need to consume the next punct
// but we may have ran out of tokens at this point
if relax_attr_tokens.next().is_none() {
break;
}
} }
let fields = match &input.data { let fields = match &input.data {