aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/grammar/expressions
diff options
context:
space:
mode:
authorDJMcNab <[email protected]>2018-12-20 12:28:59 +0000
committerDJMcNab <[email protected]>2018-12-20 12:28:59 +0000
commit27e814e182b97f8097121aceea8b42a4d4ea31b7 (patch)
treed50c1b1dbaabcef9dd39e8a4de582eb883c4b3fa /crates/ra_syntax/src/grammar/expressions
parent5205c016e9f704796aa7893f89ef108248bda2e2 (diff)
Simplify NO_BLOCK testing
Diffstat (limited to 'crates/ra_syntax/src/grammar/expressions')
-rw-r--r--crates/ra_syntax/src/grammar/expressions/atom.rs9
1 files changed, 3 insertions, 6 deletions
diff --git a/crates/ra_syntax/src/grammar/expressions/atom.rs b/crates/ra_syntax/src/grammar/expressions/atom.rs
index fcc0a4490..3b5749318 100644
--- a/crates/ra_syntax/src/grammar/expressions/atom.rs
+++ b/crates/ra_syntax/src/grammar/expressions/atom.rs
@@ -36,10 +36,11 @@ pub(crate) fn literal(p: &mut Parser) -> Option<CompletedMarker> {
36} 36}
37 37
38// E.g. for after the break in `if break {}`, this should not match 38// E.g. for after the break in `if break {}`, this should not match
39pub(super) const ATOM_EXPR_FIRST_NO_BLOCK: TokenSet = token_set_union![ 39pub(super) const ATOM_EXPR_FIRST: TokenSet = token_set_union![
40 LITERAL_FIRST, 40 LITERAL_FIRST,
41 token_set![ 41 token_set![
42 L_PAREN, 42 L_PAREN,
43 L_CURLY,
43 L_BRACK, 44 L_BRACK,
44 PIPE, 45 PIPE,
45 MOVE_KW, 46 MOVE_KW,
@@ -59,9 +60,6 @@ pub(super) const ATOM_EXPR_FIRST_NO_BLOCK: TokenSet = token_set_union![
59 ], 60 ],
60]; 61];
61 62
62pub(super) const ATOM_EXPR_FIRST: TokenSet =
63 token_set_union![ATOM_EXPR_FIRST_NO_BLOCK, token_set![L_CURLY],];
64
65const EXPR_RECOVERY_SET: TokenSet = token_set![LET_KW]; 63const EXPR_RECOVERY_SET: TokenSet = token_set![LET_KW];
66 64
67pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMarker, BlockLike)> { 65pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMarker, BlockLike)> {
@@ -442,8 +440,7 @@ fn break_expr(p: &mut Parser, r: Restrictions) -> CompletedMarker {
442 // for i in break {} 440 // for i in break {}
443 // match break {} 441 // match break {}
444 // } 442 // }
445 if r.forbid_structs && p.at_ts(EXPR_FIRST_NO_BLOCK) || !r.forbid_structs && p.at_ts(EXPR_FIRST) 443 if p.at_ts(EXPR_FIRST) && !(r.forbid_structs && p.at(L_CURLY)) {
446 {
447 expr(p); 444 expr(p);
448 } 445 }
449 m.complete(p, BREAK_EXPR) 446 m.complete(p, BREAK_EXPR)