diff options
| author | Without Boats <woboats@gmail.com> | 2016-12-09 10:54:05 -0800 |
|---|---|---|
| committer | Without Boats <woboats@gmail.com> | 2016-12-09 10:54:05 -0800 |
| commit | 90f6219f496596233d504244cfbbdbded7df5a30 (patch) | |
| tree | 06f9d0374661b9110da781493d5c7f478cb44ad6 /src/libsyntax | |
| parent | 6a495f71fffbc4b378c032295c0fc3ad20bc7e5e (diff) | |
| download | rust-90f6219f496596233d504244cfbbdbded7df5a30.tar.gz rust-90f6219f496596233d504244cfbbdbded7df5a30.zip | |
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 bdd1606805f..f6cebdc372f 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -4377,6 +4377,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 { + return Err(self.fatal("TODO How to even explain this error?")); + } + } + } + let mut parsed_something = false; loop { let lo = self.span.lo; |
