mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 04:53:34 +00:00
Fix Immovable generator syntax (static ||) not recognized #11448
This commit is contained in:
parent
4449a336f6
commit
ccab6afabc
4 changed files with 20 additions and 1 deletions
|
@ -74,6 +74,7 @@ pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMar
|
||||||
T![|] => closure_expr(p),
|
T![|] => closure_expr(p),
|
||||||
T![move] if la == T![|] => closure_expr(p),
|
T![move] if la == T![|] => closure_expr(p),
|
||||||
T![async] if la == T![|] || (la == T![move] && p.nth(2) == T![|]) => closure_expr(p),
|
T![async] if la == T![|] || (la == T![move] && p.nth(2) == T![|]) => closure_expr(p),
|
||||||
|
T![static] if la == T![|] => closure_expr(p),
|
||||||
T![if] => if_expr(p),
|
T![if] => if_expr(p),
|
||||||
|
|
||||||
T![loop] => loop_expr(p, None),
|
T![loop] => loop_expr(p, None),
|
||||||
|
@ -234,6 +235,7 @@ fn array_expr(p: &mut Parser) -> CompletedMarker {
|
||||||
// async || {};
|
// async || {};
|
||||||
// move || {};
|
// move || {};
|
||||||
// async move || {};
|
// async move || {};
|
||||||
|
// static || {};
|
||||||
// }
|
// }
|
||||||
fn closure_expr(p: &mut Parser) -> CompletedMarker {
|
fn closure_expr(p: &mut Parser) -> CompletedMarker {
|
||||||
assert!(
|
assert!(
|
||||||
|
@ -241,10 +243,12 @@ fn closure_expr(p: &mut Parser) -> CompletedMarker {
|
||||||
|| (p.at(T![move]) && p.nth(1) == T![|])
|
|| (p.at(T![move]) && p.nth(1) == T![|])
|
||||||
|| (p.at(T![async]) && p.nth(1) == T![|])
|
|| (p.at(T![async]) && p.nth(1) == T![|])
|
||||||
|| (p.at(T![async]) && p.nth(1) == T![move] && p.nth(2) == T![|])
|
|| (p.at(T![async]) && p.nth(1) == T![move] && p.nth(2) == T![|])
|
||||||
|
|| (p.at(T![static]) && p.nth(1) == T![|])
|
||||||
);
|
);
|
||||||
let m = p.start();
|
let m = p.start();
|
||||||
p.eat(T![async]);
|
p.eat(T![async]);
|
||||||
p.eat(T![move]);
|
p.eat(T![move]);
|
||||||
|
p.eat(T![static]);
|
||||||
params::param_list_closure(p);
|
params::param_list_closure(p);
|
||||||
if opt_ret_type(p) {
|
if opt_ret_type(p) {
|
||||||
// test lambda_ret_block
|
// test lambda_ret_block
|
||||||
|
|
|
@ -230,7 +230,7 @@ fn opt_item_without_modifiers(p: &mut Parser, m: Marker) -> Result<(), Marker> {
|
||||||
IDENT if p.at_contextual_kw(T![macro_rules]) && p.nth(1) == BANG => macro_rules(p, m),
|
IDENT if p.at_contextual_kw(T![macro_rules]) && p.nth(1) == BANG => macro_rules(p, m),
|
||||||
|
|
||||||
T![const] if (la == IDENT || la == T![_] || la == T![mut]) => consts::konst(p, m),
|
T![const] if (la == IDENT || la == T![_] || la == T![mut]) => consts::konst(p, m),
|
||||||
T![static] => consts::static_(p, m),
|
T![static] if (la != PIPE ) => consts::static_(p, m),
|
||||||
|
|
||||||
_ => return Err(m),
|
_ => return Err(m),
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,4 +6,5 @@ fn foo() {
|
||||||
async || {};
|
async || {};
|
||||||
move || {};
|
move || {};
|
||||||
async move || {};
|
async move || {};
|
||||||
|
static || {};
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,6 +135,20 @@ SOURCE_FILE
|
||||||
L_CURLY "{"
|
L_CURLY "{"
|
||||||
R_CURLY "}"
|
R_CURLY "}"
|
||||||
SEMICOLON ";"
|
SEMICOLON ";"
|
||||||
|
WHITESPACE "\n "
|
||||||
|
EXPR_STMT
|
||||||
|
CLOSURE_EXPR
|
||||||
|
STATIC_KW "static"
|
||||||
|
WHITESPACE " "
|
||||||
|
PARAM_LIST
|
||||||
|
PIPE "|"
|
||||||
|
PIPE "|"
|
||||||
|
WHITESPACE " "
|
||||||
|
BLOCK_EXPR
|
||||||
|
STMT_LIST
|
||||||
|
L_CURLY "{"
|
||||||
|
R_CURLY "}"
|
||||||
|
SEMICOLON ";"
|
||||||
WHITESPACE "\n"
|
WHITESPACE "\n"
|
||||||
R_CURLY "}"
|
R_CURLY "}"
|
||||||
WHITESPACE "\n"
|
WHITESPACE "\n"
|
||||||
|
|
Loading…
Reference in a new issue