From 0f9940494e9d6e28960bd9bc6562545bd5a8e320 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Tue, 5 Oct 2021 21:29:32 -0400 Subject: [PATCH] Tweak TraitObject parser to work like ImplTrait parser --- src/ty.rs | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/src/ty.rs b/src/ty.rs index ebfb96a9d8..e671221649 100644 --- a/src/ty.rs +++ b/src/ty.rs @@ -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) {