@@ -4875,6 +4875,7 @@ impl<'a> Parser<'a> {
4875
4875
self . check_keyword ( keywords:: For ) ||
4876
4876
self . check ( & token:: OpenDelim ( token:: Paren ) ) ;
4877
4877
if is_bound_start {
4878
+ let lo = self . span ;
4878
4879
let has_parens = self . eat ( & token:: OpenDelim ( token:: Paren ) ) ;
4879
4880
let question = if self . eat ( & token:: Question ) { Some ( self . prev_span ) } else { None } ;
4880
4881
if self . token . is_lifetime ( ) {
@@ -4883,10 +4884,15 @@ impl<'a> Parser<'a> {
4883
4884
"`?` may only modify trait bounds, not lifetime bounds" ) ;
4884
4885
}
4885
4886
bounds. push ( RegionTyParamBound ( self . expect_lifetime ( ) ) ) ;
4887
+ if has_parens {
4888
+ self . expect ( & token:: CloseDelim ( token:: Paren ) ) ?;
4889
+ }
4886
4890
} else {
4887
- let lo = self . span ;
4888
4891
let lifetime_defs = self . parse_late_bound_lifetime_defs ( ) ?;
4889
4892
let path = self . parse_path ( PathStyle :: Type ) ?;
4893
+ if has_parens {
4894
+ self . expect ( & token:: CloseDelim ( token:: Paren ) ) ?;
4895
+ }
4890
4896
let poly_trait = PolyTraitRef :: new ( lifetime_defs, path, lo. to ( self . prev_span ) ) ;
4891
4897
let modifier = if question. is_some ( ) {
4892
4898
TraitBoundModifier :: Maybe
@@ -4896,7 +4902,6 @@ impl<'a> Parser<'a> {
4896
4902
bounds. push ( TraitTyParamBound ( poly_trait, modifier) ) ;
4897
4903
}
4898
4904
if has_parens {
4899
- self . expect ( & token:: CloseDelim ( token:: Paren ) ) ?;
4900
4905
if let Some ( & RegionTyParamBound ( ..) ) = bounds. last ( ) {
4901
4906
self . span_err ( self . prev_span ,
4902
4907
"parenthesized lifetime bounds are not supported" ) ;
0 commit comments