Skip to content

Commit

Permalink
Tweak TraitObject parser to work like ImplTrait parser
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Oct 6, 2021
1 parent 3d6b666 commit 0f99404
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions src/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -887,24 +887,20 @@ pub mod parsing {
dyn_token: input.parse()?,
bounds: {
let mut bounds = Punctuated::new();
if allow_plus {
loop {
bounds.push_value(input.parse()?);
if !input.peek(Token![+]) {
break;
}
bounds.push_punct(input.parse()?);
if !(input.peek(Ident::peek_any)
|| input.peek(Token![::])
|| input.peek(Token![?])
|| input.peek(Lifetime)
|| input.peek(token::Paren))
{
break;
}
}
} else {
loop {
bounds.push_value(input.parse()?);
if !(allow_plus && input.peek(Token![+])) {
break;
}
bounds.push_punct(input.parse()?);
if !(input.peek(Ident::peek_any)
|| input.peek(Token![::])
|| input.peek(Token![?])
|| input.peek(Lifetime)
|| input.peek(token::Paren))
{
break;
}
}
// Just lifetimes like `'a + 'b` is not a TraitObject.
if !at_least_one_type(&bounds) {
Expand Down

0 comments on commit 0f99404

Please sign in to comment.