Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 2008607

Browse files
committed
support static move too
1 parent 1284bc0 commit 2008607

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

crates/parser/src/grammar/expressions/atom.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMar
7474
T![|] => closure_expr(p),
7575
T![move] if la == T![|] => closure_expr(p),
7676
T![async] if la == T![|] || (la == T![move] && p.nth(2) == T![|]) => closure_expr(p),
77-
T![static] if la == T![|] => closure_expr(p),
77+
T![static] if la == T![|] || (la == T![move] && p.nth(2) == T![|]) => closure_expr(p),
7878
T![if] => if_expr(p),
7979

8080
T![loop] => loop_expr(p, None),
@@ -236,6 +236,7 @@ fn array_expr(p: &mut Parser) -> CompletedMarker {
236236
// move || {};
237237
// async move || {};
238238
// static || {};
239+
// static move || {};
239240
// }
240241
fn closure_expr(p: &mut Parser) -> CompletedMarker {
241242
assert!(
@@ -244,11 +245,12 @@ fn closure_expr(p: &mut Parser) -> CompletedMarker {
244245
|| (p.at(T![async]) && p.nth(1) == T![|])
245246
|| (p.at(T![async]) && p.nth(1) == T![move] && p.nth(2) == T![|])
246247
|| (p.at(T![static]) && p.nth(1) == T![|])
248+
|| (p.at(T![static]) && p.nth(1) == T![move] && p.nth(2) == T![|])
247249
);
248250
let m = p.start();
249251
p.eat(T![async]);
250-
p.eat(T![move]);
251252
p.eat(T![static]);
253+
p.eat(T![move]);
252254
params::param_list_closure(p);
253255
if opt_ret_type(p) {
254256
// test lambda_ret_block

crates/parser/src/grammar/items.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ fn opt_item_without_modifiers(p: &mut Parser, m: Marker) -> Result<(), Marker> {
230230
IDENT if p.at_contextual_kw(T![macro_rules]) && p.nth(1) == BANG => macro_rules(p, m),
231231

232232
T![const] if (la == IDENT || la == T![_] || la == T![mut]) => consts::konst(p, m),
233-
T![static] if la != PIPE => consts::static_(p, m),
233+
T![static] if (la != PIPE && la != T![move] ) => consts::static_(p, m),
234234

235235
_ => return Err(m),
236236
};

crates/parser/test_data/parser/inline/ok/0106_lambda_expr.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ fn foo() {
77
move || {};
88
async move || {};
99
static || {};
10+
static move || {};
1011
}

crates/parser/test_data/parser/inline/ok/0106_lambda_expr.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,22 @@ SOURCE_FILE
149149
L_CURLY "{"
150150
R_CURLY "}"
151151
SEMICOLON ";"
152+
WHITESPACE "\n "
153+
EXPR_STMT
154+
CLOSURE_EXPR
155+
STATIC_KW "static"
156+
WHITESPACE " "
157+
MOVE_KW "move"
158+
WHITESPACE " "
159+
PARAM_LIST
160+
PIPE "|"
161+
PIPE "|"
162+
WHITESPACE " "
163+
BLOCK_EXPR
164+
STMT_LIST
165+
L_CURLY "{"
166+
R_CURLY "}"
167+
SEMICOLON ";"
152168
WHITESPACE "\n"
153169
R_CURLY "}"
154170
WHITESPACE "\n"

0 commit comments

Comments
 (0)