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.rs14
-rw-r--r--crates/ra_parser/src/grammar/items.rs2
2 files changed, 13 insertions, 3 deletions
diff --git a/crates/ra_parser/src/grammar/expressions/atom.rs b/crates/ra_parser/src/grammar/expressions/atom.rs
index b82fa17cb..8dc7e44a9 100644
--- a/crates/ra_parser/src/grammar/expressions/atom.rs
+++ b/crates/ra_parser/src/grammar/expressions/atom.rs
@@ -69,6 +69,7 @@ pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMar
69 L_BRACK => array_expr(p), 69 L_BRACK => array_expr(p),
70 PIPE => lambda_expr(p), 70 PIPE => lambda_expr(p),
71 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),
72 IF_KW => if_expr(p), 73 IF_KW => if_expr(p),
73 74
74 LOOP_KW => loop_expr(p, None), 75 LOOP_KW => loop_expr(p, None),
@@ -93,7 +94,7 @@ pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMar
93 } 94 }
94 } 95 }
95 } 96 }
96 ASYNC_KW if la == L_CURLY || la == MOVE_KW => { 97 ASYNC_KW if la == L_CURLY || (la == MOVE_KW && p.nth(2) == L_CURLY) => {
97 let m = p.start(); 98 let m = p.start();
98 p.bump(); 99 p.bump();
99 p.eat(MOVE_KW); 100 p.eat(MOVE_KW);
@@ -191,10 +192,19 @@ fn array_expr(p: &mut Parser) -> CompletedMarker {
191// || -> i32 { 92 }; 192// || -> i32 { 92 };
192// |x| x; 193// |x| x;
193// move |x: i32,| x; 194// move |x: i32,| x;
195// async || {};
196// move || {};
197// async move || {};
194// } 198// }
195fn lambda_expr(p: &mut Parser) -> CompletedMarker { 199fn lambda_expr(p: &mut Parser) -> CompletedMarker {
196 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 );
197 let m = p.start(); 206 let m = p.start();
207 p.eat(ASYNC_KW);
198 p.eat(MOVE_KW); 208 p.eat(MOVE_KW);
199 params::param_list_opt_types(p); 209 params::param_list_opt_types(p);
200 if opt_fn_ret_type(p) { 210 if opt_fn_ret_type(p) {
diff --git a/crates/ra_parser/src/grammar/items.rs b/crates/ra_parser/src/grammar/items.rs
index 8d8828652..c4b8ef3c7 100644
--- a/crates/ra_parser/src/grammar/items.rs
+++ b/crates/ra_parser/src/grammar/items.rs
@@ -82,7 +82,7 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Resul
82 // test_err async_without_semicolon 82 // test_err async_without_semicolon
83 // fn foo() { let _ = async {} } 83 // fn foo() { let _ = async {} }
84 has_mods |= p.eat(CONST_KW); 84 has_mods |= p.eat(CONST_KW);
85 if p.at(ASYNC_KW) && p.nth(1) != L_CURLY && p.nth(1) != MOVE_KW { 85 if p.at(ASYNC_KW) && p.nth(1) != L_CURLY && p.nth(1) != MOVE_KW && p.nth(1) != PIPE {
86 p.eat(ASYNC_KW); 86 p.eat(ASYNC_KW);
87 has_mods = true; 87 has_mods = true;
88 } 88 }