diff options
| author | bors <bors@rust-lang.org> | 2018-06-10 20:09:22 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-06-10 20:09:22 +0000 |
| commit | a805a2a5ebba2802f432d79874e59c24e398f82a (patch) | |
| tree | ef60205bdc07e3c79fed7bf2df5609bca11db3ce /src/libsyntax/parse/parser.rs | |
| parent | cabb679bf1bf37d34b0de3d60f655cf5e4185db6 (diff) | |
| parent | dc87d0d1fbe416d637f8f8f5a2f499e794862dd5 (diff) | |
| download | rust-a805a2a5ebba2802f432d79874e59c24e398f82a.tar.gz rust-a805a2a5ebba2802f432d79874e59c24e398f82a.zip | |
Auto merge of #50205 - topecongiro:include-parens-to-type-parameter, r=petrochenkov
Include parens to type parameter The motivation of this PR is to fix a bug in rustfmt (cc https://github.com/rust-lang-nursery/rustfmt/issues/2630).
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index ab2371626c3..97fcf70f531 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -4746,6 +4746,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() { @@ -4754,10 +4755,17 @@ 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))?; + self.span_err(self.prev_span, + "parenthesized lifetime bounds are not supported"); + } } 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 @@ -4766,13 +4774,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"); - } - } } else { break } |
