From 8b8953d071232bbc526f17d1bb170bd7ab0f191e Mon Sep 17 00:00:00 2001 From: naskya Date: Tue, 16 Jul 2024 23:32:10 +0900 Subject: [PATCH] fix: correctly parse top-level attribute --- crates/relax-macros/src/lib.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/relax-macros/src/lib.rs b/crates/relax-macros/src/lib.rs index bc22927..7ffd119 100644 --- a/crates/relax-macros/src/lib.rs +++ b/crates/relax-macros/src/lib.rs @@ -78,6 +78,7 @@ fn derive_impl(input: syn::DeriveInput) -> syn::Result { // * ident + punct // * ident + group + punct // * ident (the last one) + // * ident + group (the last one) let ident: syn::Ident = syn::parse2(token.into_token_stream())?; @@ -104,6 +105,12 @@ fn derive_impl(input: syn::DeriveInput) -> syn::Result { }; 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 {