@@ -427,10 +427,8 @@ impl<'a> Parser<'a> {
427427 }
428428
429429 /// Parses a bound according to the grammar:
430- ///
431430 /// ```
432431 /// BOUND = TY_BOUND | LT_BOUND
433- /// LT_BOUND = LIFETIME (e.g., `'a`)
434432 /// ```
435433 fn parse_generic_bound (
436434 & mut self ,
@@ -443,14 +441,7 @@ impl<'a> Parser<'a> {
443441 let is_negative = self . eat ( & token:: Not ) ;
444442 let question = if self . eat ( & token:: Question ) { Some ( self . prev_span ) } else { None } ;
445443 if self . token . is_lifetime ( ) {
446- self . error_opt_out_lifetime ( question) ;
447- let bound = GenericBound :: Outlives ( self . expect_lifetime ( ) ) ;
448- if has_parens {
449- // FIXME(Centril): Consider not erroring here and accepting `('lt)` instead,
450- // possibly introducing `GenericBound::Paren(P<GenericBound>)`?
451- self . recover_paren_lifetime ( lo, inner_lo) ?;
452- }
453- Ok ( Ok ( bound) )
444+ Ok ( Ok ( self . parse_generic_lt_bound ( lo, inner_lo, has_parens, question) ?) )
454445 } else {
455446 let ( poly_span, bound) = self . parse_generic_ty_bound ( lo, has_parens, question) ?;
456447 if is_negative {
@@ -461,6 +452,27 @@ impl<'a> Parser<'a> {
461452 }
462453 }
463454
455+ /// Parses a lifetime ("outlives") bound, e.g. `'a`, according to:
456+ /// ```
457+ /// LT_BOUND = LIFETIME
458+ /// ```
459+ fn parse_generic_lt_bound (
460+ & mut self ,
461+ lo : Span ,
462+ inner_lo : Span ,
463+ has_parens : bool ,
464+ question : Option < Span > ,
465+ ) -> PResult < ' a , GenericBound > {
466+ self . error_opt_out_lifetime ( question) ;
467+ let bound = GenericBound :: Outlives ( self . expect_lifetime ( ) ) ;
468+ if has_parens {
469+ // FIXME(Centril): Consider not erroring here and accepting `('lt)` instead,
470+ // possibly introducing `GenericBound::Paren(P<GenericBound>)`?
471+ self . recover_paren_lifetime ( lo, inner_lo) ?;
472+ }
473+ Ok ( bound)
474+ }
475+
464476 fn error_opt_out_lifetime ( & self , question : Option < Span > ) {
465477 if let Some ( span) = question {
466478 self . struct_span_err ( span, "`?` may only modify trait bounds, not lifetime bounds" )
0 commit comments