mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 04:53:34 +00:00
fix handle static async and static async move
This commit is contained in:
parent
3ed19d54db
commit
0a18a050b5
4 changed files with 54 additions and 3 deletions
|
@ -74,7 +74,14 @@ pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMar
|
|||
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![static] if la == T![|] || (la == T![move] && p.nth(2) == T![|]) => closure_expr(p),
|
||||
T![static]
|
||||
if la == T![|]
|
||||
|| (la == T![move] && p.nth(2) == T![|])
|
||||
|| (la == T![async] && p.nth(2) == T![|])
|
||||
|| (la == T![async] && p.nth(2) == T![move] && p.nth(3) == T![|]) =>
|
||||
{
|
||||
closure_expr(p)
|
||||
}
|
||||
T![if] => if_expr(p),
|
||||
|
||||
T![loop] => loop_expr(p, None),
|
||||
|
@ -237,6 +244,8 @@ fn array_expr(p: &mut Parser) -> CompletedMarker {
|
|||
// async move || {};
|
||||
// static || {};
|
||||
// static move || {};
|
||||
// static async || {};
|
||||
// static async move || {};
|
||||
// }
|
||||
fn closure_expr(p: &mut Parser) -> CompletedMarker {
|
||||
assert!(
|
||||
|
@ -246,10 +255,15 @@ fn closure_expr(p: &mut Parser) -> CompletedMarker {
|
|||
|| (p.at(T![async]) && p.nth(1) == T![move] && p.nth(2) == T![|])
|
||||
|| (p.at(T![static]) && p.nth(1) == T![|])
|
||||
|| (p.at(T![static]) && p.nth(1) == T![move] && p.nth(2) == T![|])
|
||||
|| (p.at(T![static]) && p.nth(1) == T![async] && p.nth(2) == T![|])
|
||||
|| (p.at(T![static])
|
||||
&& p.nth(1) == T![async]
|
||||
&& p.nth(2) == T![move]
|
||||
&& p.nth(3) == T![|])
|
||||
);
|
||||
let m = p.start();
|
||||
p.eat(T![async]);
|
||||
p.eat(T![static]);
|
||||
p.eat(T![async]);
|
||||
p.eat(T![move]);
|
||||
params::param_list_closure(p);
|
||||
if opt_ret_type(p) {
|
||||
|
@ -257,6 +271,7 @@ fn closure_expr(p: &mut Parser) -> CompletedMarker {
|
|||
// fn main() { || -> i32 { 92 }(); }
|
||||
block_expr(p);
|
||||
} else if p.at_ts(EXPR_FIRST) {
|
||||
println!("gg");
|
||||
expr(p);
|
||||
} else {
|
||||
p.error("expected expression");
|
||||
|
|
|
@ -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),
|
||||
|
||||
T![const] if (la == IDENT || la == T![_] || la == T![mut]) => consts::konst(p, m),
|
||||
T![static] if (la != PIPE && la != T![move]) => consts::static_(p, m),
|
||||
T![static] if (la != PIPE && la != T![move] && la != T![async]) => consts::static_(p, m),
|
||||
|
||||
_ => return Err(m),
|
||||
};
|
||||
|
|
|
@ -8,4 +8,6 @@ fn foo() {
|
|||
async move || {};
|
||||
static || {};
|
||||
static move || {};
|
||||
static async || {};
|
||||
static async move || {};
|
||||
}
|
||||
|
|
|
@ -166,5 +166,39 @@ SOURCE_FILE
|
|||
R_CURLY "}"
|
||||
SEMICOLON ";"
|
||||
WHITESPACE "\n "
|
||||
EXPR_STMT
|
||||
CLOSURE_EXPR
|
||||
STATIC_KW "static"
|
||||
WHITESPACE " "
|
||||
ASYNC_KW "async"
|
||||
WHITESPACE " "
|
||||
PARAM_LIST
|
||||
PIPE "|"
|
||||
PIPE "|"
|
||||
WHITESPACE " "
|
||||
BLOCK_EXPR
|
||||
STMT_LIST
|
||||
L_CURLY "{"
|
||||
R_CURLY "}"
|
||||
SEMICOLON ";"
|
||||
WHITESPACE "\n "
|
||||
EXPR_STMT
|
||||
CLOSURE_EXPR
|
||||
STATIC_KW "static"
|
||||
WHITESPACE " "
|
||||
ASYNC_KW "async"
|
||||
WHITESPACE " "
|
||||
MOVE_KW "move"
|
||||
WHITESPACE " "
|
||||
PARAM_LIST
|
||||
PIPE "|"
|
||||
PIPE "|"
|
||||
WHITESPACE " "
|
||||
BLOCK_EXPR
|
||||
STMT_LIST
|
||||
L_CURLY "{"
|
||||
R_CURLY "}"
|
||||
SEMICOLON ";"
|
||||
WHITESPACE "\n"
|
||||
R_CURLY "}"
|
||||
WHITESPACE "\n"
|
||||
|
|
Loading…
Reference in a new issue