diff options
author | Aleksey Kladov <[email protected]> | 2020-05-02 00:18:19 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-05-02 10:21:39 +0100 |
commit | 4f2134cc33f07c09fe166cec42971828843bc0ef (patch) | |
tree | 0e2440d51717dd0dfcefbf77e5ef546f1ee5c60d /crates/ra_parser/src/grammar/expressions | |
parent | 3c96de5380a09fe06752ce146edeb017ae8c701c (diff) |
Introduce EffectExpr
Diffstat (limited to 'crates/ra_parser/src/grammar/expressions')
-rw-r--r-- | crates/ra_parser/src/grammar/expressions/atom.rs | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/crates/ra_parser/src/grammar/expressions/atom.rs b/crates/ra_parser/src/grammar/expressions/atom.rs index 166dfc472..c76b7330c 100644 --- a/crates/ra_parser/src/grammar/expressions/atom.rs +++ b/crates/ra_parser/src/grammar/expressions/atom.rs | |||
@@ -92,7 +92,10 @@ pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMar | |||
92 | T![loop] => loop_expr(p, Some(m)), | 92 | T![loop] => loop_expr(p, Some(m)), |
93 | T![for] => for_expr(p, Some(m)), | 93 | T![for] => for_expr(p, Some(m)), |
94 | T![while] => while_expr(p, Some(m)), | 94 | T![while] => while_expr(p, Some(m)), |
95 | T!['{'] => block_expr(p, Some(m)), | 95 | T!['{'] => { |
96 | block_expr(p); | ||
97 | m.complete(p, EFFECT_EXPR) | ||
98 | } | ||
96 | _ => { | 99 | _ => { |
97 | // test_err misplaced_label_err | 100 | // test_err misplaced_label_err |
98 | // fn main() { | 101 | // fn main() { |
@@ -108,13 +111,15 @@ pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMar | |||
108 | let m = p.start(); | 111 | let m = p.start(); |
109 | p.bump(T![async]); | 112 | p.bump(T![async]); |
110 | p.eat(T![move]); | 113 | p.eat(T![move]); |
111 | block_expr(p, Some(m)) | 114 | block_expr(p); |
115 | m.complete(p, EFFECT_EXPR) | ||
112 | } | 116 | } |
113 | T![match] => match_expr(p), | 117 | T![match] => match_expr(p), |
114 | T![unsafe] if la == T!['{'] => { | 118 | T![unsafe] if la == T!['{'] => { |
115 | let m = p.start(); | 119 | let m = p.start(); |
116 | p.bump(T![unsafe]); | 120 | p.bump(T![unsafe]); |
117 | block_expr(p, Some(m)) | 121 | block_expr(p); |
122 | m.complete(p, EFFECT_EXPR) | ||
118 | } | 123 | } |
119 | T!['{'] => { | 124 | T!['{'] => { |
120 | // test for_range_from | 125 | // test for_range_from |
@@ -123,7 +128,7 @@ pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMar | |||
123 | // break; | 128 | // break; |
124 | // } | 129 | // } |
125 | // } | 130 | // } |
126 | block_expr(p, None) | 131 | block_expr(p) |
127 | } | 132 | } |
128 | T![return] => return_expr(p), | 133 | T![return] => return_expr(p), |
129 | T![continue] => continue_expr(p), | 134 | T![continue] => continue_expr(p), |
@@ -134,7 +139,7 @@ pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMar | |||
134 | } | 139 | } |
135 | }; | 140 | }; |
136 | let blocklike = match done.kind() { | 141 | let blocklike = match done.kind() { |
137 | IF_EXPR | WHILE_EXPR | FOR_EXPR | LOOP_EXPR | MATCH_EXPR | BLOCK_EXPR | TRY_BLOCK_EXPR => { | 142 | IF_EXPR | WHILE_EXPR | FOR_EXPR | LOOP_EXPR | MATCH_EXPR | BLOCK_EXPR | EFFECT_EXPR => { |
138 | BlockLike::Block | 143 | BlockLike::Block |
139 | } | 144 | } |
140 | _ => BlockLike::NotBlock, | 145 | _ => BlockLike::NotBlock, |
@@ -234,7 +239,7 @@ fn lambda_expr(p: &mut Parser) -> CompletedMarker { | |||
234 | if p.at(T!['{']) { | 239 | if p.at(T!['{']) { |
235 | // test lambda_ret_block | 240 | // test lambda_ret_block |
236 | // fn main() { || -> i32 { 92 }(); } | 241 | // fn main() { || -> i32 { 92 }(); } |
237 | block_expr(p, None); | 242 | block_expr(p); |
238 | } else { | 243 | } else { |
239 | p.error("expected `{`"); | 244 | p.error("expected `{`"); |
240 | } | 245 | } |
@@ -464,10 +469,12 @@ fn match_guard(p: &mut Parser) -> CompletedMarker { | |||
464 | // unsafe {}; | 469 | // unsafe {}; |
465 | // 'label: {}; | 470 | // 'label: {}; |
466 | // } | 471 | // } |
467 | pub(super) fn block_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker { | 472 | pub(super) fn block_expr(p: &mut Parser) -> CompletedMarker { |
468 | assert!(p.at(T!['{'])); | 473 | assert!(p.at(T!['{'])); |
469 | let m = m.unwrap_or_else(|| p.start()); | 474 | let m = p.start(); |
470 | naked_block(p); | 475 | p.bump(T!['{']); |
476 | expr_block_contents(p); | ||
477 | p.expect(T!['}']); | ||
471 | m.complete(p, BLOCK_EXPR) | 478 | m.complete(p, BLOCK_EXPR) |
472 | } | 479 | } |
473 | 480 | ||
@@ -552,8 +559,8 @@ fn try_block_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker { | |||
552 | } | 559 | } |
553 | 560 | ||
554 | p.bump(T![try]); | 561 | p.bump(T![try]); |
555 | block(p); | 562 | block_expr(p); |
556 | m.complete(p, TRY_EXPR) | 563 | m.complete(p, EFFECT_EXPR) |
557 | } | 564 | } |
558 | 565 | ||
559 | // test box_expr | 566 | // test box_expr |