mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
Allow types to the left of : in where predicates.
This commit is contained in:
parent
b59334e67a
commit
1059ec74e2
1 changed files with 27 additions and 24 deletions
|
@ -104,22 +104,32 @@ pub(super) fn opt_where_clause(p: &mut Parser) {
|
||||||
}
|
}
|
||||||
let m = p.start();
|
let m = p.start();
|
||||||
p.bump();
|
p.bump();
|
||||||
loop {
|
|
||||||
if !(paths::is_path_start(p)
|
if is_where_clause_end(p) {
|
||||||
|| p.current() == LIFETIME
|
// Empty where clause
|
||||||
|| p.current() == FOR_KW
|
} else {
|
||||||
|| p.current() == L_ANGLE)
|
loop {
|
||||||
{
|
where_predicate(p);
|
||||||
break;
|
|
||||||
}
|
let comma = p.eat(COMMA);
|
||||||
where_predicate(p);
|
|
||||||
if p.current() != L_CURLY && p.current() != SEMI && p.current() != EQ {
|
if is_where_clause_end(p) {
|
||||||
p.expect(COMMA);
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if !comma {
|
||||||
|
p.error("expected comma")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m.complete(p, WHERE_CLAUSE);
|
m.complete(p, WHERE_CLAUSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_where_clause_end(p: &mut Parser) -> bool {
|
||||||
|
p.current() == L_CURLY || p.current() == SEMI || p.current() == EQ
|
||||||
|
}
|
||||||
|
|
||||||
fn where_predicate(p: &mut Parser) {
|
fn where_predicate(p: &mut Parser) {
|
||||||
let m = p.start();
|
let m = p.start();
|
||||||
match p.current() {
|
match p.current() {
|
||||||
|
@ -131,20 +141,13 @@ fn where_predicate(p: &mut Parser) {
|
||||||
p.error("expected colon");
|
p.error("expected colon");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
IMPL_KW => {
|
||||||
|
p.error("expected lifetime or type");
|
||||||
|
return;
|
||||||
|
}
|
||||||
_ => {
|
_ => {
|
||||||
// test where_pred_for
|
types::type_(p);
|
||||||
// fn test<F>()
|
|
||||||
// where
|
|
||||||
// for<'a> F: Fn(&'a str)
|
|
||||||
// { }
|
|
||||||
if p.at(FOR_KW) {
|
|
||||||
types::for_binder(p);
|
|
||||||
}
|
|
||||||
if paths::is_path_start(p) || p.at(L_ANGLE) {
|
|
||||||
types::path_type_(p, false);
|
|
||||||
} else {
|
|
||||||
p.error("expected a type");
|
|
||||||
}
|
|
||||||
if p.at(COLON) {
|
if p.at(COLON) {
|
||||||
bounds(p);
|
bounds(p);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue