Skip to content

Commit

Permalink
Improve errors on unexpected token in precise capture bound
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jul 21, 2024
1 parent 11b2371 commit 788f8cb
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -775,18 +775,24 @@ pub(crate) mod parsing {
if cfg!(feature = "full") && input.peek(Token![use]) {
input.parse::<Token![use]>()?;
input.parse::<Token![<]>()?;
while !input.peek(Token![>]) {
if input.peek(Lifetime) {
loop {
let lookahead = input.lookahead1();
if lookahead.peek(Lifetime) {
input.parse::<Lifetime>()?;
} else if input.peek(Ident) {
} else if lookahead.peek(Ident) {
input.parse::<Ident>()?;
} else {
} else if lookahead.peek(Token![>]) {
break;
} else {
return Err(lookahead.error());
}
if input.peek(Token![,]) {
let lookahead = input.lookahead1();
if lookahead.peek(Token![,]) {
input.parse::<Token![,]>()?;
} else {
} else if lookahead.peek(Token![>]) {
break;
} else {
return Err(lookahead.error());
}
}
input.parse::<Token![>]>()?;
Expand Down

0 comments on commit 788f8cb

Please sign in to comment.