aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_parser
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-09-02 17:33:02 +0100
committerAleksey Kladov <[email protected]>2019-09-02 18:15:51 +0100
commit3c2dea7f55830ba2391e5eb8525cdbb43ac666c2 (patch)
tree4856efbfaf1b52e441bd7bd8a5f6a26e454edb07 /crates/ra_parser
parenta8397deab914240aca8f015fb3736689919c0a5b (diff)
always wrap block into an expression
Diffstat (limited to 'crates/ra_parser')
-rw-r--r--crates/ra_parser/src/grammar.rs2
-rw-r--r--crates/ra_parser/src/grammar/expressions.rs5
-rw-r--r--crates/ra_parser/src/grammar/expressions/atom.rs4
3 files changed, 8 insertions, 3 deletions
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(
144 parent: Option<SyntaxKind>, 144 parent: Option<SyntaxKind>,
145) -> Option<fn(&mut Parser)> { 145) -> Option<fn(&mut Parser)> {
146 let res = match node { 146 let res = match node {
147 BLOCK => expressions::block, 147 BLOCK => expressions::naked_block,
148 RECORD_FIELD_DEF_LIST => items::record_field_def_list, 148 RECORD_FIELD_DEF_LIST => items::record_field_def_list,
149 RECORD_FIELD_LIST => items::record_field_list, 149 RECORD_FIELD_LIST => items::record_field_list,
150 ENUM_VARIANT_LIST => items::enum_variant_list, 150 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) {
40 p.error("expected a block"); 40 p.error("expected a block");
41 return; 41 return;
42 } 42 }
43 atom::block_expr(p, None);
44}
45
46pub(crate) fn naked_block(p: &mut Parser) {
47 assert!(p.at(T!['{']));
43 let m = p.start(); 48 let m = p.start();
44 p.bump(); 49 p.bump();
45 expr_block_contents(p); 50 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 {
463// unsafe {}; 463// unsafe {};
464// 'label: {}; 464// 'label: {};
465// } 465// }
466fn block_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker { 466pub(super) fn block_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker {
467 assert!(p.at(T!['{'])); 467 assert!(p.at(T!['{']));
468 let m = m.unwrap_or_else(|| p.start()); 468 let m = m.unwrap_or_else(|| p.start());
469 block(p); 469 naked_block(p);
470 m.complete(p, BLOCK_EXPR) 470 m.complete(p, BLOCK_EXPR)
471} 471}
472 472