diff --git a/impl/Cargo.toml b/impl/Cargo.toml index 563271a..a768f96 100644 --- a/impl/Cargo.toml +++ b/impl/Cargo.toml @@ -14,7 +14,7 @@ proc-macro = true [dependencies] proc-macro2 = "1.0.74" quote = "1.0.35" -syn = "2.0.46" +syn = "2.0.86" [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/impl/src/attr.rs b/impl/src/attr.rs index e59b519..a3746b0 100644 --- a/impl/src/attr.rs +++ b/impl/src/attr.rs @@ -2,7 +2,7 @@ use proc_macro2::{Delimiter, Group, Literal, Punct, Spacing, Span, TokenStream, use quote::{format_ident, quote, ToTokens}; use std::collections::BTreeSet as Set; use syn::parse::discouraged::Speculative; -use syn::parse::ParseStream; +use syn::parse::{End, ParseStream}; use syn::{ braced, bracketed, parenthesized, token, Attribute, Error, Ident, Index, LitFloat, LitInt, LitStr, Meta, Result, Token, @@ -111,10 +111,8 @@ fn parse_error_attribute<'a>(attrs: &mut Attrs<'a>, attr: &'a Attribute) -> Resu return Err(lookahead.error()); }; - let ahead = input.fork(); - ahead.parse::>()?; - let args = if ahead.is_empty() { - input.advance_to(&ahead); + let args = if input.is_empty() || input.peek(Token![,]) && input.peek2(End) { + input.parse::>()?; TokenStream::new() } else { parse_token_expr(input, false)?