@@ -4875,6 +4875,7 @@ impl<'a> Parser<'a> {
48754875 self . check_keyword ( keywords:: For ) ||
48764876 self . check ( & token:: OpenDelim ( token:: Paren ) ) ;
48774877 if is_bound_start {
4878+ let lo = self . span ;
48784879 let has_parens = self . eat ( & token:: OpenDelim ( token:: Paren ) ) ;
48794880 let question = if self . eat ( & token:: Question ) { Some ( self . prev_span ) } else { None } ;
48804881 if self . token . is_lifetime ( ) {
@@ -4883,10 +4884,15 @@ impl<'a> Parser<'a> {
48834884 "`?` may only modify trait bounds, not lifetime bounds" ) ;
48844885 }
48854886 bounds. push ( RegionTyParamBound ( self . expect_lifetime ( ) ) ) ;
4887+ if has_parens {
4888+ self . expect ( & token:: CloseDelim ( token:: Paren ) ) ?;
4889+ }
48864890 } else {
4887- let lo = self . span ;
48884891 let lifetime_defs = self . parse_late_bound_lifetime_defs ( ) ?;
48894892 let path = self . parse_path ( PathStyle :: Type ) ?;
4893+ if has_parens {
4894+ self . expect ( & token:: CloseDelim ( token:: Paren ) ) ?;
4895+ }
48904896 let poly_trait = PolyTraitRef :: new ( lifetime_defs, path, lo. to ( self . prev_span ) ) ;
48914897 let modifier = if question. is_some ( ) {
48924898 TraitBoundModifier :: Maybe
@@ -4896,7 +4902,6 @@ impl<'a> Parser<'a> {
48964902 bounds. push ( TraitTyParamBound ( poly_trait, modifier) ) ;
48974903 }
48984904 if has_parens {
4899- self . expect ( & token:: CloseDelim ( token:: Paren ) ) ?;
49004905 if let Some ( & RegionTyParamBound ( ..) ) = bounds. last ( ) {
49014906 self . span_err ( self . prev_span ,
49024907 "parenthesized lifetime bounds are not supported" ) ;
0 commit comments