Skip to content

Commit

Permalink
Use peek2(End) instead of fork/advance_to
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Oct 31, 2024
1 parent a9a6c98 commit 3d79a90
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion impl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
8 changes: 3 additions & 5 deletions impl/src/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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::<Option<Token![,]>>()?;
let args = if ahead.is_empty() {
input.advance_to(&ahead);
let args = if input.is_empty() || input.peek(Token![,]) && input.peek2(End) {
input.parse::<Option<Token![,]>>()?;
TokenStream::new()
} else {
parse_token_expr(input, false)?
Expand Down

0 comments on commit 3d79a90

Please sign in to comment.