diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-03-31 10:18:21 +0100 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-03-31 10:18:21 +0100 |
commit | 4666138c910a655deb0e8129b0a1dc5974b49bdf (patch) | |
tree | 57dd67f7e9a6dd28515045f5f10fabbc7931c3b4 /crates | |
parent | c5ca49678f129045e59438df279829902034ec71 (diff) | |
parent | c7264b4f07604649a2b46db816c3a3bc2d5728a6 (diff) |
Merge #1072
1072: recognize async move blocks r=matklad a=memoryruins
closes #1053
Co-authored-by: memoryruins <[email protected]>
Diffstat (limited to 'crates')
4 files changed, 43 insertions, 3 deletions
diff --git a/crates/ra_parser/src/grammar/expressions/atom.rs b/crates/ra_parser/src/grammar/expressions/atom.rs index a23977bfb..8653d4055 100644 --- a/crates/ra_parser/src/grammar/expressions/atom.rs +++ b/crates/ra_parser/src/grammar/expressions/atom.rs | |||
@@ -92,10 +92,10 @@ pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMar | |||
92 | } | 92 | } |
93 | } | 93 | } |
94 | } | 94 | } |
95 | 95 | ASYNC_KW if la == L_CURLY || la == MOVE_KW => { | |
96 | ASYNC_KW if la == L_CURLY => { | ||
97 | let m = p.start(); | 96 | let m = p.start(); |
98 | p.bump(); | 97 | p.bump(); |
98 | p.eat(MOVE_KW); | ||
99 | block_expr(p, Some(m)) | 99 | block_expr(p, Some(m)) |
100 | } | 100 | } |
101 | MATCH_KW => match_expr(p), | 101 | MATCH_KW => match_expr(p), |
diff --git a/crates/ra_parser/src/grammar/items.rs b/crates/ra_parser/src/grammar/items.rs index c24e6d1e0..8d8828652 100644 --- a/crates/ra_parser/src/grammar/items.rs +++ b/crates/ra_parser/src/grammar/items.rs | |||
@@ -82,7 +82,7 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Resul | |||
82 | // test_err async_without_semicolon | 82 | // test_err async_without_semicolon |
83 | // fn foo() { let _ = async {} } | 83 | // fn foo() { let _ = async {} } |
84 | has_mods |= p.eat(CONST_KW); | 84 | has_mods |= p.eat(CONST_KW); |
85 | if p.at(ASYNC_KW) && p.nth(1) != L_CURLY { | 85 | if p.at(ASYNC_KW) && p.nth(1) != L_CURLY && p.nth(1) != MOVE_KW { |
86 | p.eat(ASYNC_KW); | 86 | p.eat(ASYNC_KW); |
87 | has_mods = true; | 87 | has_mods = true; |
88 | } | 88 | } |
diff --git a/crates/ra_syntax/tests/data/parser/ok/0049_async_block.rs b/crates/ra_syntax/tests/data/parser/ok/0049_async_block.rs new file mode 100644 index 000000000..4781b3225 --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/ok/0049_async_block.rs | |||
@@ -0,0 +1,5 @@ | |||
1 | fn foo() { | ||
2 | async {}; | ||
3 | async move {}; | ||
4 | } | ||
5 | |||
diff --git a/crates/ra_syntax/tests/data/parser/ok/0049_async_block.txt b/crates/ra_syntax/tests/data/parser/ok/0049_async_block.txt new file mode 100644 index 000000000..6212e1130 --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/ok/0049_async_block.txt | |||
@@ -0,0 +1,35 @@ | |||
1 | SOURCE_FILE@[0; 47) | ||
2 | FN_DEF@[0; 45) | ||
3 | FN_KW@[0; 2) | ||
4 | WHITESPACE@[2; 3) | ||
5 | NAME@[3; 6) | ||
6 | IDENT@[3; 6) "foo" | ||
7 | PARAM_LIST@[6; 8) | ||
8 | L_PAREN@[6; 7) | ||
9 | R_PAREN@[7; 8) | ||
10 | WHITESPACE@[8; 9) | ||
11 | BLOCK@[9; 45) | ||
12 | L_CURLY@[9; 10) | ||
13 | WHITESPACE@[10; 15) | ||
14 | EXPR_STMT@[15; 24) | ||
15 | BLOCK_EXPR@[15; 23) | ||
16 | ASYNC_KW@[15; 20) | ||
17 | WHITESPACE@[20; 21) | ||
18 | BLOCK@[21; 23) | ||
19 | L_CURLY@[21; 22) | ||
20 | R_CURLY@[22; 23) | ||
21 | SEMI@[23; 24) | ||
22 | WHITESPACE@[24; 29) | ||
23 | EXPR_STMT@[29; 43) | ||
24 | BLOCK_EXPR@[29; 42) | ||
25 | ASYNC_KW@[29; 34) | ||
26 | WHITESPACE@[34; 35) | ||
27 | MOVE_KW@[35; 39) | ||
28 | WHITESPACE@[39; 40) | ||
29 | BLOCK@[40; 42) | ||
30 | L_CURLY@[40; 41) | ||
31 | R_CURLY@[41; 42) | ||
32 | SEMI@[42; 43) | ||
33 | WHITESPACE@[43; 44) | ||
34 | R_CURLY@[44; 45) | ||
35 | WHITESPACE@[45; 47) | ||