diff options
| author | Seiichi Uchida <seiichi.uchida@dena.com> | 2018-04-27 17:32:54 +0900 |
|---|---|---|
| committer | Seiichi Uchida <seuchida@gmail.com> | 2018-06-10 10:37:38 +0900 |
| commit | 78a19d9b88d499449e53ebfb89301b36810e3c34 (patch) | |
| tree | 0147216779f839be1159acc544bee6cdd47acb35 /src/libsyntax/parse/parser.rs | |
| parent | 2a0062974a5225847fc43d5522c4dc3718173fe5 (diff) | |
| download | rust-78a19d9b88d499449e53ebfb89301b36810e3c34.tar.gz rust-78a19d9b88d499449e53ebfb89301b36810e3c34.zip | |
Include parens to type parameter
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 53d0b5529ef..5428842c7f7 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -4875,6 +4875,7 @@ impl<'a> Parser<'a> { self.check_keyword(keywords::For) || self.check(&token::OpenDelim(token::Paren)); if is_bound_start { + let lo = self.span; let has_parens = self.eat(&token::OpenDelim(token::Paren)); let question = if self.eat(&token::Question) { Some(self.prev_span) } else { None }; if self.token.is_lifetime() { @@ -4883,10 +4884,15 @@ impl<'a> Parser<'a> { "`?` may only modify trait bounds, not lifetime bounds"); } bounds.push(RegionTyParamBound(self.expect_lifetime())); + if has_parens { + self.expect(&token::CloseDelim(token::Paren))?; + } } else { - let lo = self.span; let lifetime_defs = self.parse_late_bound_lifetime_defs()?; let path = self.parse_path(PathStyle::Type)?; + if has_parens { + self.expect(&token::CloseDelim(token::Paren))?; + } let poly_trait = PolyTraitRef::new(lifetime_defs, path, lo.to(self.prev_span)); let modifier = if question.is_some() { TraitBoundModifier::Maybe @@ -4896,7 +4902,6 @@ impl<'a> Parser<'a> { bounds.push(TraitTyParamBound(poly_trait, modifier)); } if has_parens { - self.expect(&token::CloseDelim(token::Paren))?; if let Some(&RegionTyParamBound(..)) = bounds.last() { self.span_err(self.prev_span, "parenthesized lifetime bounds are not supported"); |
