diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-12-19 21:22:00 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-12-19 21:22:00 +0000 |
commit | ef1e107df147a82b74089ab9797ce35effe24e5e (patch) | |
tree | e54a25733ffc2c3b19385b299779d763615cb81e /crates/ra_syntax/src/grammar/expressions/atom.rs | |
parent | 0e1c01cdb8e6b346edd5d68d9cc72cbce1ce9793 (diff) | |
parent | a3b842fb8b7b5503b1c4fc49355edd4f2fe0d28d (diff) |
Merge #273
273: Add a test to ensure that we can parse each file r=matklad a=DJMcNab
Note that this has a non-spurious failure in ra_analysis/src/mock_analysis.
Probably fixes #195.
If my understanding is correct, fixes #214 and fixes #225.
Co-authored-by: DJMcNab <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src/grammar/expressions/atom.rs')
-rw-r--r-- | crates/ra_syntax/src/grammar/expressions/atom.rs | 13 |
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 | ||
62 | const EXPR_RECOVERY_SET: TokenSet = token_set![LET_KW]; | 62 | const EXPR_RECOVERY_SET: TokenSet = token_set![LET_KW]; |
63 | 63 | ||
64 | pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<CompletedMarker> { | 64 | pub(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); |