diff options
Diffstat (limited to 'crates/ra_parser/src/grammar/expressions/atom.rs')
-rw-r--r-- | crates/ra_parser/src/grammar/expressions/atom.rs | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/crates/ra_parser/src/grammar/expressions/atom.rs b/crates/ra_parser/src/grammar/expressions/atom.rs index a23977bfb..8dc7e44a9 100644 --- a/crates/ra_parser/src/grammar/expressions/atom.rs +++ b/crates/ra_parser/src/grammar/expressions/atom.rs | |||
@@ -51,6 +51,7 @@ pub(super) const ATOM_EXPR_FIRST: TokenSet = | |||
51 | BREAK_KW, | 51 | BREAK_KW, |
52 | CONTINUE_KW, | 52 | CONTINUE_KW, |
53 | LIFETIME, | 53 | LIFETIME, |
54 | ASYNC_KW, | ||
54 | ]); | 55 | ]); |
55 | 56 | ||
56 | const EXPR_RECOVERY_SET: TokenSet = token_set![LET_KW]; | 57 | const EXPR_RECOVERY_SET: TokenSet = token_set![LET_KW]; |
@@ -68,6 +69,7 @@ pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMar | |||
68 | L_BRACK => array_expr(p), | 69 | L_BRACK => array_expr(p), |
69 | PIPE => lambda_expr(p), | 70 | PIPE => lambda_expr(p), |
70 | MOVE_KW if la == PIPE => lambda_expr(p), | 71 | MOVE_KW if la == PIPE => lambda_expr(p), |
72 | ASYNC_KW if la == PIPE || (la == MOVE_KW && p.nth(2) == PIPE) => lambda_expr(p), | ||
71 | IF_KW => if_expr(p), | 73 | IF_KW => if_expr(p), |
72 | 74 | ||
73 | LOOP_KW => loop_expr(p, None), | 75 | LOOP_KW => loop_expr(p, None), |
@@ -92,10 +94,10 @@ pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMar | |||
92 | } | 94 | } |
93 | } | 95 | } |
94 | } | 96 | } |
95 | 97 | ASYNC_KW if la == L_CURLY || (la == MOVE_KW && p.nth(2) == L_CURLY) => { | |
96 | ASYNC_KW if la == L_CURLY => { | ||
97 | let m = p.start(); | 98 | let m = p.start(); |
98 | p.bump(); | 99 | p.bump(); |
100 | p.eat(MOVE_KW); | ||
99 | block_expr(p, Some(m)) | 101 | block_expr(p, Some(m)) |
100 | } | 102 | } |
101 | MATCH_KW => match_expr(p), | 103 | MATCH_KW => match_expr(p), |
@@ -190,10 +192,19 @@ fn array_expr(p: &mut Parser) -> CompletedMarker { | |||
190 | // || -> i32 { 92 }; | 192 | // || -> i32 { 92 }; |
191 | // |x| x; | 193 | // |x| x; |
192 | // move |x: i32,| x; | 194 | // move |x: i32,| x; |
195 | // async || {}; | ||
196 | // move || {}; | ||
197 | // async move || {}; | ||
193 | // } | 198 | // } |
194 | fn lambda_expr(p: &mut Parser) -> CompletedMarker { | 199 | fn lambda_expr(p: &mut Parser) -> CompletedMarker { |
195 | assert!(p.at(PIPE) || (p.at(MOVE_KW) && p.nth(1) == PIPE)); | 200 | assert!( |
201 | p.at(PIPE) | ||
202 | || (p.at(MOVE_KW) && p.nth(1) == PIPE) | ||
203 | || (p.at(ASYNC_KW) && p.nth(1) == PIPE) | ||
204 | || (p.at(ASYNC_KW) && p.nth(1) == MOVE_KW && p.nth(2) == PIPE) | ||
205 | ); | ||
196 | let m = p.start(); | 206 | let m = p.start(); |
207 | p.eat(ASYNC_KW); | ||
197 | p.eat(MOVE_KW); | 208 | p.eat(MOVE_KW); |
198 | params::param_list_opt_types(p); | 209 | params::param_list_opt_types(p); |
199 | if opt_fn_ret_type(p) { | 210 | if opt_fn_ret_type(p) { |