From 27e814e182b97f8097121aceea8b42a4d4ea31b7 Mon Sep 17 00:00:00 2001 From: DJMcNab <36049421+DJMcNab@users.noreply.github.com> Date: Thu, 20 Dec 2018 12:28:59 +0000 Subject: Simplify NO_BLOCK testing --- crates/ra_syntax/src/grammar/expressions/atom.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'crates/ra_syntax/src/grammar/expressions') 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 { } // E.g. for after the break in `if break {}`, this should not match -pub(super) const ATOM_EXPR_FIRST_NO_BLOCK: TokenSet = token_set_union![ +pub(super) const ATOM_EXPR_FIRST: TokenSet = token_set_union![ LITERAL_FIRST, token_set![ L_PAREN, + L_CURLY, L_BRACK, PIPE, MOVE_KW, @@ -59,9 +60,6 @@ pub(super) const ATOM_EXPR_FIRST_NO_BLOCK: TokenSet = token_set_union![ ], ]; -pub(super) const ATOM_EXPR_FIRST: TokenSet = - token_set_union![ATOM_EXPR_FIRST_NO_BLOCK, token_set![L_CURLY],]; - const EXPR_RECOVERY_SET: TokenSet = token_set![LET_KW]; pub(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 { // for i in break {} // match break {} // } - if r.forbid_structs && p.at_ts(EXPR_FIRST_NO_BLOCK) || !r.forbid_structs && p.at_ts(EXPR_FIRST) - { + if p.at_ts(EXPR_FIRST) && !(r.forbid_structs && p.at(L_CURLY)) { expr(p); } m.complete(p, BREAK_EXPR) -- cgit v1.2.3