mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
Fix parsing lambdas with return type
We should eat only a single block, and not whatever larger expression may start with a block. closes #3721
This commit is contained in:
parent
785eb32f49
commit
f6188caaa0
4 changed files with 75 additions and 21 deletions
|
@ -230,14 +230,20 @@ fn lambda_expr(p: &mut Parser) -> CompletedMarker {
|
|||
p.eat(T![async]);
|
||||
p.eat(T![move]);
|
||||
params::param_list_closure(p);
|
||||
if opt_fn_ret_type(p) && !p.at(T!['{']) {
|
||||
p.error("expected `{`");
|
||||
}
|
||||
|
||||
if p.at_ts(EXPR_FIRST) {
|
||||
expr(p);
|
||||
if opt_fn_ret_type(p) {
|
||||
if p.at(T!['{']) {
|
||||
// test lambda_ret_block
|
||||
// fn main() { || -> i32 { 92 }(); }
|
||||
block_expr(p, None);
|
||||
} else {
|
||||
p.error("expected `{`");
|
||||
}
|
||||
} else {
|
||||
p.error("expected expression");
|
||||
if p.at_ts(EXPR_FIRST) {
|
||||
expr(p);
|
||||
} else {
|
||||
p.error("expected expression");
|
||||
}
|
||||
}
|
||||
m.complete(p, LAMBDA_EXPR)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue