aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_parser/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_parser/src')
-rw-r--r--crates/ra_parser/src/grammar/expressions.rs19
1 files changed, 12 insertions, 7 deletions
diff --git a/crates/ra_parser/src/grammar/expressions.rs b/crates/ra_parser/src/grammar/expressions.rs
index 9fd3a235d..742076c1a 100644
--- a/crates/ra_parser/src/grammar/expressions.rs
+++ b/crates/ra_parser/src/grammar/expressions.rs
@@ -359,11 +359,14 @@ fn lhs(
359 return Some((m.complete(p, RANGE_EXPR), BlockLike::NotBlock)); 359 return Some((m.complete(p, RANGE_EXPR), BlockLike::NotBlock));
360 } 360 }
361 _ => { 361 _ => {
362 // test expression_after_block
363 // fn foo() {
364 // let mut p = F{x: 5};
365 // {p}.x = 10;
366 // }
367 //
362 let (lhs, blocklike) = atom::atom_expr(p, r)?; 368 let (lhs, blocklike) = atom::atom_expr(p, r)?;
363 return Some(( 369 return Some(postfix_expr(p, lhs, blocklike, !(r.prefer_stmt && blocklike.is_block())));
364 postfix_expr(p, lhs, !(r.prefer_stmt && blocklike.is_block())),
365 blocklike,
366 ));
367 } 370 }
368 }; 371 };
369 expr_bp(p, r, 255, dollar_lvl); 372 expr_bp(p, r, 255, dollar_lvl);
@@ -376,8 +379,9 @@ fn postfix_expr(
376 // Calls are disallowed if the type is a block and we prefer statements because the call cannot be disambiguated from a tuple 379 // Calls are disallowed if the type is a block and we prefer statements because the call cannot be disambiguated from a tuple
377 // E.g. `while true {break}();` is parsed as 380 // E.g. `while true {break}();` is parsed as
378 // `while true {break}; ();` 381 // `while true {break}; ();`
382 mut block_like: BlockLike,
379 mut allow_calls: bool, 383 mut allow_calls: bool,
380) -> CompletedMarker { 384) -> (CompletedMarker, BlockLike) {
381 loop { 385 loop {
382 lhs = match p.current() { 386 lhs = match p.current() {
383 // test stmt_postfix_expr_ambiguity 387 // test stmt_postfix_expr_ambiguity
@@ -417,9 +421,10 @@ fn postfix_expr(
417 T![as] => cast_expr(p, lhs), 421 T![as] => cast_expr(p, lhs),
418 _ => break, 422 _ => break,
419 }; 423 };
420 allow_calls = true 424 allow_calls = true;
425 block_like = BlockLike::NotBlock;
421 } 426 }
422 lhs 427 (lhs, block_like)
423} 428}
424 429
425// test call_expr 430// test call_expr