Skip to content

Commit e2e9da3

Browse files
authored
Merge pull request #328 from dtolnay/peekend
Use peek2(End) instead of fork/advance_to
2 parents a9a6c98 + 3d79a90 commit e2e9da3

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

impl/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ proc-macro = true
1414
[dependencies]
1515
proc-macro2 = "1.0.74"
1616
quote = "1.0.35"
17-
syn = "2.0.46"
17+
syn = "2.0.86"
1818

1919
[package.metadata.docs.rs]
2020
targets = ["x86_64-unknown-linux-gnu"]

impl/src/attr.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use proc_macro2::{Delimiter, Group, Literal, Punct, Spacing, Span, TokenStream,
22
use quote::{format_ident, quote, ToTokens};
33
use std::collections::BTreeSet as Set;
44
use syn::parse::discouraged::Speculative;
5-
use syn::parse::ParseStream;
5+
use syn::parse::{End, ParseStream};
66
use syn::{
77
braced, bracketed, parenthesized, token, Attribute, Error, Ident, Index, LitFloat, LitInt,
88
LitStr, Meta, Result, Token,
@@ -111,10 +111,8 @@ fn parse_error_attribute<'a>(attrs: &mut Attrs<'a>, attr: &'a Attribute) -> Resu
111111
return Err(lookahead.error());
112112
};
113113

114-
let ahead = input.fork();
115-
ahead.parse::<Option<Token![,]>>()?;
116-
let args = if ahead.is_empty() {
117-
input.advance_to(&ahead);
114+
let args = if input.is_empty() || input.peek(Token![,]) && input.peek2(End) {
115+
input.parse::<Option<Token![,]>>()?;
118116
TokenStream::new()
119117
} else {
120118
parse_token_expr(input, false)?

0 commit comments

Comments
 (0)