aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_parser/src/grammar
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-03-25 15:41:50 +0000
committerAleksey Kladov <[email protected]>2020-03-25 16:01:28 +0000
commitf6188caaa0d226bef88418c9ff3f13a63ae95358 (patch)
tree86cd80fad18be823a01cf945762f35b12d34eec5 /crates/ra_parser/src/grammar
parent785eb32f49653fbc5789396af4fa6ad61f89fb38 (diff)
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
Diffstat (limited to 'crates/ra_parser/src/grammar')
-rw-r--r--crates/ra_parser/src/grammar/expressions/atom.rs20
1 files changed, 13 insertions, 7 deletions
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 {
230 p.eat(T![async]); 230 p.eat(T![async]);
231 p.eat(T![move]); 231 p.eat(T![move]);
232 params::param_list_closure(p); 232 params::param_list_closure(p);
233 if opt_fn_ret_type(p) && !p.at(T!['{']) { 233 if opt_fn_ret_type(p) {
234 p.error("expected `{`"); 234 if p.at(T!['{']) {
235 } 235 // test lambda_ret_block
236 236 // fn main() { || -> i32 { 92 }(); }
237 if p.at_ts(EXPR_FIRST) { 237 block_expr(p, None);
238 expr(p); 238 } else {
239 p.error("expected `{`");
240 }
239 } else { 241 } else {
240 p.error("expected expression"); 242 if p.at_ts(EXPR_FIRST) {
243 expr(p);
244 } else {
245 p.error("expected expression");
246 }
241 } 247 }
242 m.complete(p, LAMBDA_EXPR) 248 m.complete(p, LAMBDA_EXPR)
243} 249}