diff options
| author | bors <bors@rust-lang.org> | 2016-12-24 00:22:00 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2016-12-24 00:22:00 +0000 |
| commit | 8d65c8d64edeadcfcc210fd70f44249d02daec41 (patch) | |
| tree | 53c2d86e1273b6912ed5c9c586abcd4f8010c8c0 /src/libsyntax | |
| parent | 4d07320d015ff762431a98cd058ea1fb70fd6c62 (diff) | |
| parent | 14e4b00933c13a4c419f2192df11b135d5bb0c85 (diff) | |
| download | rust-8d65c8d64edeadcfcc210fd70f44249d02daec41.tar.gz rust-8d65c8d64edeadcfcc210fd70f44249d02daec41.zip | |
Auto merge of #38268 - withoutboats:parse_where_higher_rank_hack, r=eddyb
Prevent where < ident > from parsing. In order to be forward compatible with `where<'a>` syntax for higher rank parameters, prevent potential conflicts with UFCS from parsing correctly for the near term.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index cd4f255b5e3..a0ed50b33a4 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -4368,6 +4368,23 @@ impl<'a> Parser<'a> { return Ok(where_clause); } + // This is a temporary hack. + // + // We are considering adding generics to the `where` keyword as an alternative higher-rank + // parameter syntax (as in `where<'a>` or `where<T>`. To avoid that being a breaking + // change, for now we refuse to parse `where < (ident | lifetime) (> | , | :)`. + if token::Lt == self.token { + let ident_or_lifetime = self.look_ahead(1, |t| t.is_ident() || t.is_lifetime()); + if ident_or_lifetime { + let gt_comma_or_colon = self.look_ahead(2, |t| { + *t == token::Gt || *t == token::Comma || *t == token::Colon + }); + if gt_comma_or_colon { + self.span_err(self.span, "syntax `where<T>` is reserved for future use"); + } + } + } + let mut parsed_something = false; loop { let lo = self.span.lo; |
