aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_parser/src/grammar
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_parser/src/grammar')
-rw-r--r--crates/ra_parser/src/grammar/expressions/atom.rs18
1 files changed, 17 insertions, 1 deletions
diff --git a/crates/ra_parser/src/grammar/expressions/atom.rs b/crates/ra_parser/src/grammar/expressions/atom.rs
index 8b1a1de49..725fb99f6 100644
--- a/crates/ra_parser/src/grammar/expressions/atom.rs
+++ b/crates/ra_parser/src/grammar/expressions/atom.rs
@@ -52,6 +52,7 @@ pub(super) const ATOM_EXPR_FIRST: TokenSet =
52 CONTINUE_KW, 52 CONTINUE_KW,
53 LIFETIME, 53 LIFETIME,
54 ASYNC_KW, 54 ASYNC_KW,
55 TRY_KW,
55 ]); 56 ]);
56 57
57const EXPR_RECOVERY_SET: TokenSet = token_set![LET_KW]; 58const EXPR_RECOVERY_SET: TokenSet = token_set![LET_KW];
@@ -75,6 +76,7 @@ pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMar
75 T![loop] => loop_expr(p, None), 76 T![loop] => loop_expr(p, None),
76 T![for] => for_expr(p, None), 77 T![for] => for_expr(p, None),
77 T![while] => while_expr(p, None), 78 T![while] => while_expr(p, None),
79 T![try] => try_block_expr(p, None),
78 LIFETIME if la == T![:] => { 80 LIFETIME if la == T![:] => {
79 let m = p.start(); 81 let m = p.start();
80 label(p); 82 label(p);
@@ -116,7 +118,9 @@ pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMar
116 } 118 }
117 }; 119 };
118 let blocklike = match done.kind() { 120 let blocklike = match done.kind() {
119 IF_EXPR | WHILE_EXPR | FOR_EXPR | LOOP_EXPR | MATCH_EXPR | BLOCK_EXPR => BlockLike::Block, 121 IF_EXPR | WHILE_EXPR | FOR_EXPR | LOOP_EXPR | MATCH_EXPR | BLOCK_EXPR | TRY_BLOCK_EXPR => {
122 BlockLike::Block
123 }
120 _ => BlockLike::NotBlock, 124 _ => BlockLike::NotBlock,
121 }; 125 };
122 Some((done, blocklike)) 126 Some((done, blocklike))
@@ -491,3 +495,15 @@ fn break_expr(p: &mut Parser, r: Restrictions) -> CompletedMarker {
491 } 495 }
492 m.complete(p, BREAK_EXPR) 496 m.complete(p, BREAK_EXPR)
493} 497}
498
499// test try_block_expr
500// fn foo() {
501// let _ = try {};
502// }
503fn try_block_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker {
504 assert!(p.at(T![try]));
505 let m = m.unwrap_or_else(|| p.start());
506 p.bump();
507 block(p);
508 m.complete(p, TRY_EXPR)
509}