aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/grammar/expressions/atom.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src/grammar/expressions/atom.rs')
-rw-r--r--crates/ra_syntax/src/grammar/expressions/atom.rs13
1 files changed, 9 insertions, 4 deletions
diff --git a/crates/ra_syntax/src/grammar/expressions/atom.rs b/crates/ra_syntax/src/grammar/expressions/atom.rs
index 04087fd60..cd7d62aff 100644
--- a/crates/ra_syntax/src/grammar/expressions/atom.rs
+++ b/crates/ra_syntax/src/grammar/expressions/atom.rs
@@ -61,9 +61,9 @@ pub(super) const ATOM_EXPR_FIRST: TokenSet = token_set_union![
61 61
62const EXPR_RECOVERY_SET: TokenSet = token_set![LET_KW]; 62const EXPR_RECOVERY_SET: TokenSet = token_set![LET_KW];
63 63
64pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<CompletedMarker> { 64pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMarker, BlockLike)> {
65 if let Some(m) = literal(p) { 65 if let Some(m) = literal(p) {
66 return Some(m); 66 return Some((m, BlockLike::NotBlock));
67 } 67 }
68 if paths::is_path_start(p) || p.at(L_ANGLE) { 68 if paths::is_path_start(p) || p.at(L_ANGLE) {
69 return Some(path_expr(p, r)); 69 return Some(path_expr(p, r));
@@ -114,7 +114,11 @@ pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<CompletedMark
114 return None; 114 return None;
115 } 115 }
116 }; 116 };
117 Some(done) 117 let blocklike = match done.kind() {
118 IF_EXPR | WHILE_EXPR | FOR_EXPR | LOOP_EXPR | MATCH_EXPR | BLOCK_EXPR => BlockLike::Block,
119 _ => BlockLike::NotBlock,
120 };
121 Some((done, blocklike))
118} 122}
119 123
120// test tuple_expr 124// test tuple_expr
@@ -349,6 +353,7 @@ pub(crate) fn match_arm_list(p: &mut Parser) {
349// fn foo() { 353// fn foo() {
350// match () { 354// match () {
351// _ => (), 355// _ => (),
356// _ if Test>{field: 0} => (),
352// X | Y if Z => (), 357// X | Y if Z => (),
353// | X | Y if Z => (), 358// | X | Y if Z => (),
354// | X => (), 359// | X => (),
@@ -362,7 +367,7 @@ fn match_arm(p: &mut Parser) -> BlockLike {
362 patterns::pattern(p); 367 patterns::pattern(p);
363 } 368 }
364 if p.eat(IF_KW) { 369 if p.eat(IF_KW) {
365 expr_no_struct(p); 370 expr(p);
366 } 371 }
367 p.expect(FAT_ARROW); 372 p.expect(FAT_ARROW);
368 let ret = expr_stmt(p); 373 let ret = expr_stmt(p);