From 3c2dea7f55830ba2391e5eb8525cdbb43ac666c2 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 2 Sep 2019 19:33:02 +0300 Subject: always wrap block into an expression --- crates/ra_parser/src/grammar.rs | 2 +- crates/ra_parser/src/grammar/expressions.rs | 5 +++++ crates/ra_parser/src/grammar/expressions/atom.rs | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) (limited to 'crates/ra_parser') diff --git a/crates/ra_parser/src/grammar.rs b/crates/ra_parser/src/grammar.rs index d0f0dd4ac..be9419e0c 100644 --- a/crates/ra_parser/src/grammar.rs +++ b/crates/ra_parser/src/grammar.rs @@ -144,7 +144,7 @@ pub(crate) fn reparser( parent: Option, ) -> Option { let res = match node { - BLOCK => expressions::block, + BLOCK => expressions::naked_block, RECORD_FIELD_DEF_LIST => items::record_field_def_list, RECORD_FIELD_LIST => items::record_field_list, ENUM_VARIANT_LIST => items::enum_variant_list, diff --git a/crates/ra_parser/src/grammar/expressions.rs b/crates/ra_parser/src/grammar/expressions.rs index 783d6a6f0..ba8386d11 100644 --- a/crates/ra_parser/src/grammar/expressions.rs +++ b/crates/ra_parser/src/grammar/expressions.rs @@ -40,6 +40,11 @@ pub(crate) fn block(p: &mut Parser) { p.error("expected a block"); return; } + atom::block_expr(p, None); +} + +pub(crate) fn naked_block(p: &mut Parser) { + assert!(p.at(T!['{'])); let m = p.start(); p.bump(); expr_block_contents(p); diff --git a/crates/ra_parser/src/grammar/expressions/atom.rs b/crates/ra_parser/src/grammar/expressions/atom.rs index bc942ae01..ec7f2441d 100644 --- a/crates/ra_parser/src/grammar/expressions/atom.rs +++ b/crates/ra_parser/src/grammar/expressions/atom.rs @@ -463,10 +463,10 @@ fn match_guard(p: &mut Parser) -> CompletedMarker { // unsafe {}; // 'label: {}; // } -fn block_expr(p: &mut Parser, m: Option) -> CompletedMarker { +pub(super) fn block_expr(p: &mut Parser, m: Option) -> CompletedMarker { assert!(p.at(T!['{'])); let m = m.unwrap_or_else(|| p.start()); - block(p); + naked_block(p); m.complete(p, BLOCK_EXPR) } -- cgit v1.2.3