From f6188caaa0d226bef88418c9ff3f13a63ae95358 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 25 Mar 2020 16:41:50 +0100 Subject: 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 --- crates/ra_parser/src/grammar/expressions/atom.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'crates/ra_parser/src/grammar/expressions/atom.rs') diff --git a/crates/ra_parser/src/grammar/expressions/atom.rs b/crates/ra_parser/src/grammar/expressions/atom.rs index 2335d99b3..0d277a586 100644 --- a/crates/ra_parser/src/grammar/expressions/atom.rs +++ b/crates/ra_parser/src/grammar/expressions/atom.rs @@ -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) } -- cgit v1.2.3