aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_parser/src/grammar/expressions
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_parser/src/grammar/expressions')
-rw-r--r--crates/ra_parser/src/grammar/expressions/atom.rs35
1 files changed, 22 insertions, 13 deletions
diff --git a/crates/ra_parser/src/grammar/expressions/atom.rs b/crates/ra_parser/src/grammar/expressions/atom.rs
index 166dfc472..efb424dae 100644
--- a/crates/ra_parser/src/grammar/expressions/atom.rs
+++ b/crates/ra_parser/src/grammar/expressions/atom.rs
@@ -92,7 +92,12 @@ 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 // test labeled_block
96 // fn f() { 'label: {}; }
97 T!['{'] => {
98 block_expr(p);
99 m.complete(p, EFFECT_EXPR)
100 }
96 _ => { 101 _ => {
97 // test_err misplaced_label_err 102 // test_err misplaced_label_err
98 // fn main() { 103 // fn main() {
@@ -108,13 +113,17 @@ pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMar
108 let m = p.start(); 113 let m = p.start();
109 p.bump(T![async]); 114 p.bump(T![async]);
110 p.eat(T![move]); 115 p.eat(T![move]);
111 block_expr(p, Some(m)) 116 block_expr(p);
117 m.complete(p, EFFECT_EXPR)
112 } 118 }
113 T![match] => match_expr(p), 119 T![match] => match_expr(p),
120 // test unsafe_block
121 // fn f() { unsafe { } }
114 T![unsafe] if la == T!['{'] => { 122 T![unsafe] if la == T!['{'] => {
115 let m = p.start(); 123 let m = p.start();
116 p.bump(T![unsafe]); 124 p.bump(T![unsafe]);
117 block_expr(p, Some(m)) 125 block_expr(p);
126 m.complete(p, EFFECT_EXPR)
118 } 127 }
119 T!['{'] => { 128 T!['{'] => {
120 // test for_range_from 129 // test for_range_from
@@ -123,7 +132,7 @@ pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMar
123 // break; 132 // break;
124 // } 133 // }
125 // } 134 // }
126 block_expr(p, None) 135 block_expr(p)
127 } 136 }
128 T![return] => return_expr(p), 137 T![return] => return_expr(p),
129 T![continue] => continue_expr(p), 138 T![continue] => continue_expr(p),
@@ -134,7 +143,7 @@ pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMar
134 } 143 }
135 }; 144 };
136 let blocklike = match done.kind() { 145 let blocklike = match done.kind() {
137 IF_EXPR | WHILE_EXPR | FOR_EXPR | LOOP_EXPR | MATCH_EXPR | BLOCK_EXPR | TRY_BLOCK_EXPR => { 146 IF_EXPR | WHILE_EXPR | FOR_EXPR | LOOP_EXPR | MATCH_EXPR | BLOCK_EXPR | EFFECT_EXPR => {
138 BlockLike::Block 147 BlockLike::Block
139 } 148 }
140 _ => BlockLike::NotBlock, 149 _ => BlockLike::NotBlock,
@@ -234,7 +243,7 @@ fn lambda_expr(p: &mut Parser) -> CompletedMarker {
234 if p.at(T!['{']) { 243 if p.at(T!['{']) {
235 // test lambda_ret_block 244 // test lambda_ret_block
236 // fn main() { || -> i32 { 92 }(); } 245 // fn main() { || -> i32 { 92 }(); }
237 block_expr(p, None); 246 block_expr(p);
238 } else { 247 } else {
239 p.error("expected `{`"); 248 p.error("expected `{`");
240 } 249 }
@@ -461,13 +470,13 @@ fn match_guard(p: &mut Parser) -> CompletedMarker {
461// test block_expr 470// test block_expr
462// fn foo() { 471// fn foo() {
463// {}; 472// {};
464// unsafe {};
465// 'label: {};
466// } 473// }
467pub(super) fn block_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker { 474pub(super) fn block_expr(p: &mut Parser) -> CompletedMarker {
468 assert!(p.at(T!['{'])); 475 assert!(p.at(T!['{']));
469 let m = m.unwrap_or_else(|| p.start()); 476 let m = p.start();
470 naked_block(p); 477 p.bump(T!['{']);
478 expr_block_contents(p);
479 p.expect(T!['}']);
471 m.complete(p, BLOCK_EXPR) 480 m.complete(p, BLOCK_EXPR)
472} 481}
473 482
@@ -552,8 +561,8 @@ fn try_block_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker {
552 } 561 }
553 562
554 p.bump(T![try]); 563 p.bump(T![try]);
555 block(p); 564 block_expr(p);
556 m.complete(p, TRY_EXPR) 565 m.complete(p, EFFECT_EXPR)
557} 566}
558 567
559// test box_expr 568// test box_expr