aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_parser
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-03-25 16:01:54 +0000
committerGitHub <[email protected]>2020-03-25 16:01:54 +0000
commit0f6fb0ec3b5ac5cd4a5e74c74813abec8257868b (patch)
tree2e5bc7a56752adfe4297daf712ad45ff8430b9a7 /crates/ra_parser
parenta69fc239257bff1cda54bc2070cb197d477bb563 (diff)
parentf6188caaa0d226bef88418c9ff3f13a63ae95358 (diff)
Merge #3722
3722: Fix parsing lambdas with return type r=matklad a=matklad We should eat only a single block, and not whatever larger expression may start with a block. closes #3721 bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_parser')
-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}