Skip to content

Commit 90f6219

Browse files
committed
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.
1 parent 6a495f7 commit 90f6219

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/libsyntax/parse/parser.rs

+17
Original file line numberDiff line numberDiff line change
@@ -4377,6 +4377,23 @@ impl<'a> Parser<'a> {
43774377
return Ok(where_clause);
43784378
}
43794379

4380+
// This is a temporary hack.
4381+
//
4382+
// We are considering adding generics to the `where` keyword as an alternative higher-rank
4383+
// parameter syntax (as in `where<'a>` or `where<T>`. To avoid that being a breaking
4384+
// change, for now we refuse to parse `where < (ident | lifetime) (> | , | :)`.
4385+
if token::Lt == self.token {
4386+
let ident_or_lifetime = self.look_ahead(1, |t| t.is_ident() || t.is_lifetime());
4387+
if ident_or_lifetime {
4388+
let gt_comma_or_colon = self.look_ahead(2, |t| {
4389+
*t == token::Gt || *t == token::Comma || *t == token::Colon
4390+
});
4391+
if gt_comma_or_colon {
4392+
return Err(self.fatal("TODO How to even explain this error?"));
4393+
}
4394+
}
4395+
}
4396+
43804397
let mut parsed_something = false;
43814398
loop {
43824399
let lo = self.span.lo;

0 commit comments

Comments
 (0)