aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_parser/src/grammar/expressions/atom.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_parser/src/grammar/expressions/atom.rs')
-rw-r--r--crates/ra_parser/src/grammar/expressions/atom.rs14
1 files changed, 12 insertions, 2 deletions
diff --git a/crates/ra_parser/src/grammar/expressions/atom.rs b/crates/ra_parser/src/grammar/expressions/atom.rs
index 8653d4055..d0feed616 100644
--- a/crates/ra_parser/src/grammar/expressions/atom.rs
+++ b/crates/ra_parser/src/grammar/expressions/atom.rs
@@ -68,6 +68,7 @@ pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMar
68 L_BRACK => array_expr(p), 68 L_BRACK => array_expr(p),
69 PIPE => lambda_expr(p), 69 PIPE => lambda_expr(p),
70 MOVE_KW if la == PIPE => lambda_expr(p), 70 MOVE_KW if la == PIPE => lambda_expr(p),
71 ASYNC_KW if la == PIPE || (la == MOVE_KW && p.nth(2) == PIPE) => lambda_expr(p),
71 IF_KW => if_expr(p), 72 IF_KW => if_expr(p),
72 73
73 LOOP_KW => loop_expr(p, None), 74 LOOP_KW => loop_expr(p, None),
@@ -92,7 +93,7 @@ pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMar
92 } 93 }
93 } 94 }
94 } 95 }
95 ASYNC_KW if la == L_CURLY || la == MOVE_KW => { 96 ASYNC_KW if la == L_CURLY || (la == MOVE_KW && p.nth(2) == L_CURLY) => {
96 let m = p.start(); 97 let m = p.start();
97 p.bump(); 98 p.bump();
98 p.eat(MOVE_KW); 99 p.eat(MOVE_KW);
@@ -190,10 +191,19 @@ fn array_expr(p: &mut Parser) -> CompletedMarker {
190// || -> i32 { 92 }; 191// || -> i32 { 92 };
191// |x| x; 192// |x| x;
192// move |x: i32,| x; 193// move |x: i32,| x;
194// async || {};
195// move || {};
196// async move || {};
193// } 197// }
194fn lambda_expr(p: &mut Parser) -> CompletedMarker { 198fn lambda_expr(p: &mut Parser) -> CompletedMarker {
195 assert!(p.at(PIPE) || (p.at(MOVE_KW) && p.nth(1) == PIPE)); 199 assert!(
200 p.at(PIPE)
201 || (p.at(MOVE_KW) && p.nth(1) == PIPE)
202 || (p.at(ASYNC_KW) && p.nth(1) == PIPE)
203 || (p.at(ASYNC_KW) && p.nth(1) == MOVE_KW && p.nth(2) == PIPE)
204 );
196 let m = p.start(); 205 let m = p.start();
206 p.eat(ASYNC_KW);
197 p.eat(MOVE_KW); 207 p.eat(MOVE_KW);
198 params::param_list_opt_types(p); 208 params::param_list_opt_types(p);
199 if opt_fn_ret_type(p) { 209 if opt_fn_ret_type(p) {