mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Merge #1072
1072: recognize async move blocks r=matklad a=memoryruins closes #1053 Co-authored-by: memoryruins <memoryruinsmusic@gmail.com>
This commit is contained in:
commit
4666138c91
@ -92,10 +92,10 @@ pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMar
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ASYNC_KW if la == L_CURLY => {
|
||||
ASYNC_KW if la == L_CURLY || la == MOVE_KW => {
|
||||
let m = p.start();
|
||||
p.bump();
|
||||
p.eat(MOVE_KW);
|
||||
block_expr(p, Some(m))
|
||||
}
|
||||
MATCH_KW => match_expr(p),
|
||||
|
@ -82,7 +82,7 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Resul
|
||||
// test_err async_without_semicolon
|
||||
// fn foo() { let _ = async {} }
|
||||
has_mods |= p.eat(CONST_KW);
|
||||
if p.at(ASYNC_KW) && p.nth(1) != L_CURLY {
|
||||
if p.at(ASYNC_KW) && p.nth(1) != L_CURLY && p.nth(1) != MOVE_KW {
|
||||
p.eat(ASYNC_KW);
|
||||
has_mods = true;
|
||||
}
|
||||
|
@ -0,0 +1,5 @@
|
||||
fn foo() {
|
||||
async {};
|
||||
async move {};
|
||||
}
|
||||
|
35
crates/ra_syntax/tests/data/parser/ok/0049_async_block.txt
Normal file
35
crates/ra_syntax/tests/data/parser/ok/0049_async_block.txt
Normal file
@ -0,0 +1,35 @@
|
||||
SOURCE_FILE@[0; 47)
|
||||
FN_DEF@[0; 45)
|
||||
FN_KW@[0; 2)
|
||||
WHITESPACE@[2; 3)
|
||||
NAME@[3; 6)
|
||||
IDENT@[3; 6) "foo"
|
||||
PARAM_LIST@[6; 8)
|
||||
L_PAREN@[6; 7)
|
||||
R_PAREN@[7; 8)
|
||||
WHITESPACE@[8; 9)
|
||||
BLOCK@[9; 45)
|
||||
L_CURLY@[9; 10)
|
||||
WHITESPACE@[10; 15)
|
||||
EXPR_STMT@[15; 24)
|
||||
BLOCK_EXPR@[15; 23)
|
||||
ASYNC_KW@[15; 20)
|
||||
WHITESPACE@[20; 21)
|
||||
BLOCK@[21; 23)
|
||||
L_CURLY@[21; 22)
|
||||
R_CURLY@[22; 23)
|
||||
SEMI@[23; 24)
|
||||
WHITESPACE@[24; 29)
|
||||
EXPR_STMT@[29; 43)
|
||||
BLOCK_EXPR@[29; 42)
|
||||
ASYNC_KW@[29; 34)
|
||||
WHITESPACE@[34; 35)
|
||||
MOVE_KW@[35; 39)
|
||||
WHITESPACE@[39; 40)
|
||||
BLOCK@[40; 42)
|
||||
L_CURLY@[40; 41)
|
||||
R_CURLY@[41; 42)
|
||||
SEMI@[42; 43)
|
||||
WHITESPACE@[43; 44)
|
||||
R_CURLY@[44; 45)
|
||||
WHITESPACE@[45; 47)
|
Loading…
Reference in New Issue
Block a user