@@ -367,19 +367,7 @@ impl<'a> Parser<'a> {
367367 let mut negative_bounds = Vec :: new ( ) ;
368368 let mut last_plus_span = None ;
369369 let mut was_negative = false ;
370- loop {
371- // This needs to be synchronized with `TokenKind::can_begin_bound`.
372- let is_bound_start = self . check_path ( )
373- || self . check_lifetime ( )
374- || self . check ( & token:: Not ) // Used for error reporting only.
375- || self . check ( & token:: Question )
376- || self . check_keyword ( kw:: For )
377- || self . check ( & token:: OpenDelim ( token:: Paren ) ) ;
378-
379- if !is_bound_start {
380- break ;
381- }
382-
370+ while self . can_begin_bound ( ) {
383371 let lo = self . token . span ;
384372 let has_parens = self . eat ( & token:: OpenDelim ( token:: Paren ) ) ;
385373 let inner_lo = self . token . span ;
@@ -456,6 +444,17 @@ impl<'a> Parser<'a> {
456444 return Ok ( bounds) ;
457445 }
458446
447+ /// Can the current token begin a bound?
448+ fn can_begin_bound ( & mut self ) -> bool {
449+ // This needs to be synchronized with `TokenKind::can_begin_bound`.
450+ self . check_path ( )
451+ || self . check_lifetime ( )
452+ || self . check ( & token:: Not ) // Used for error reporting only.
453+ || self . check ( & token:: Question )
454+ || self . check_keyword ( kw:: For )
455+ || self . check ( & token:: OpenDelim ( token:: Paren ) )
456+ }
457+
459458 fn error_opt_out_lifetime ( & self , question : Option < Span > ) {
460459 if let Some ( span) = question {
461460 self . struct_span_err ( span, "`?` may only modify trait bounds, not lifetime bounds" )
0 commit comments