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

Commit ccab6af

Browse files
committed
Fix Immovable generator syntax (static ||) not recognized rust-lang#11448
1 parent 4449a33 commit ccab6af

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +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),
7778
T![if] => if_expr(p),
7879

7980
T![loop] => loop_expr(p, None),
@@ -234,17 +235,20 @@ fn array_expr(p: &mut Parser) -> CompletedMarker {
234235
// async || {};
235236
// move || {};
236237
// async move || {};
238+
// static || {};
237239
// }
238240
fn closure_expr(p: &mut Parser) -> CompletedMarker {
239241
assert!(
240242
p.at(T![|])
241243
|| (p.at(T![move]) && p.nth(1) == T![|])
242244
|| (p.at(T![async]) && p.nth(1) == T![|])
243245
|| (p.at(T![async]) && p.nth(1) == T![move] && p.nth(2) == T![|])
246+
|| (p.at(T![static]) && p.nth(1) == T![|])
244247
);
245248
let m = p.start();
246249
p.eat(T![async]);
247250
p.eat(T![move]);
251+
p.eat(T![static]);
248252
params::param_list_closure(p);
249253
if opt_ret_type(p) {
250254
// 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] => consts::static_(p, m),
233+
T![static] if (la != PIPE ) => 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
@@ -6,4 +6,5 @@ fn foo() {
66
async || {};
77
move || {};
88
async move || {};
9+
static || {};
910
}

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,20 @@ SOURCE_FILE
135135
L_CURLY "{"
136136
R_CURLY "}"
137137
SEMICOLON ";"
138+
WHITESPACE "\n "
139+
EXPR_STMT
140+
CLOSURE_EXPR
141+
STATIC_KW "static"
142+
WHITESPACE " "
143+
PARAM_LIST
144+
PIPE "|"
145+
PIPE "|"
146+
WHITESPACE " "
147+
BLOCK_EXPR
148+
STMT_LIST
149+
L_CURLY "{"
150+
R_CURLY "}"
151+
SEMICOLON ";"
138152
WHITESPACE "\n"
139153
R_CURLY "}"
140154
WHITESPACE "\n"

0 commit comments

Comments
 (0)