aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-07-20 10:00:35 +0100
committerbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-07-20 10:00:35 +0100
commit2830d1376b05794c7bf1467fe52ad3bc0eb4ca41 (patch)
tree7a717bb2a51489b4e1bc50895bff45f1e217f15c /crates/ra_syntax
parente18f8495d6569f4fc0b7457b65a1d199cf7b5974 (diff)
parent3a7f07c62d3dd253d63c483ee291d9471f539479 (diff)
Merge #1558
1558: Support .await syntax r=matklad a=unrealhoang - [x] Add `await` keyword to grammar, parser for await_expr - [ ] Infer type for await_expr Co-authored-by: Unreal Hoang <[email protected]>
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r--crates/ra_syntax/src/grammar.ron2
-rw-r--r--crates/ra_syntax/tests/data/parser/inline/ok/0137_await_expr.rs5
-rw-r--r--crates/ra_syntax/tests/data/parser/inline/ok/0137_await_expr.txt67
3 files changed, 74 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron
index 6c075a700..55494239e 100644
--- a/crates/ra_syntax/src/grammar.ron
+++ b/crates/ra_syntax/src/grammar.ron
@@ -97,6 +97,7 @@ Grammar(
97 "return", 97 "return",
98 "try", 98 "try",
99 "box", 99 "box",
100 "await"
100 ], 101 ],
101 contextual_keywords: [ 102 contextual_keywords: [
102 "auto", 103 "auto",
@@ -200,6 +201,7 @@ Grammar(
200 "INDEX_EXPR", 201 "INDEX_EXPR",
201 "METHOD_CALL_EXPR", 202 "METHOD_CALL_EXPR",
202 "FIELD_EXPR", 203 "FIELD_EXPR",
204 "AWAIT_EXPR",
203 "TRY_EXPR", 205 "TRY_EXPR",
204 "CAST_EXPR", 206 "CAST_EXPR",
205 207
diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0137_await_expr.rs b/crates/ra_syntax/tests/data/parser/inline/ok/0137_await_expr.rs
new file mode 100644
index 000000000..d2ba89ca6
--- /dev/null
+++ b/crates/ra_syntax/tests/data/parser/inline/ok/0137_await_expr.rs
@@ -0,0 +1,5 @@
1fn foo() {
2 x.await;
3 x.0.await;
4 x.0().await?.hello();
5}
diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0137_await_expr.txt b/crates/ra_syntax/tests/data/parser/inline/ok/0137_await_expr.txt
new file mode 100644
index 000000000..99bd76ace
--- /dev/null
+++ b/crates/ra_syntax/tests/data/parser/inline/ok/0137_await_expr.txt
@@ -0,0 +1,67 @@
1SOURCE_FILE@[0; 67)
2 FN_DEF@[0; 66)
3 FN_KW@[0; 2) "fn"
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; 66)
12 L_CURLY@[9; 10) "{"
13 WHITESPACE@[10; 15) "\n "
14 EXPR_STMT@[15; 23)
15 AWAIT_EXPR@[15; 22)
16 PATH_EXPR@[15; 16)
17 PATH@[15; 16)
18 PATH_SEGMENT@[15; 16)
19 NAME_REF@[15; 16)
20 IDENT@[15; 16) "x"
21 DOT@[16; 17) "."
22 AWAIT_KW@[17; 22) "await"
23 SEMI@[22; 23) ";"
24 WHITESPACE@[23; 28) "\n "
25 EXPR_STMT@[28; 38)
26 AWAIT_EXPR@[28; 37)
27 FIELD_EXPR@[28; 31)
28 PATH_EXPR@[28; 29)
29 PATH@[28; 29)
30 PATH_SEGMENT@[28; 29)
31 NAME_REF@[28; 29)
32 IDENT@[28; 29) "x"
33 DOT@[29; 30) "."
34 INT_NUMBER@[30; 31) "0"
35 DOT@[31; 32) "."
36 AWAIT_KW@[32; 37) "await"
37 SEMI@[37; 38) ";"
38 WHITESPACE@[38; 43) "\n "
39 EXPR_STMT@[43; 64)
40 METHOD_CALL_EXPR@[43; 63)
41 TRY_EXPR@[43; 55)
42 AWAIT_EXPR@[43; 54)
43 CALL_EXPR@[43; 48)
44 FIELD_EXPR@[43; 46)
45 PATH_EXPR@[43; 44)
46 PATH@[43; 44)
47 PATH_SEGMENT@[43; 44)
48 NAME_REF@[43; 44)
49 IDENT@[43; 44) "x"
50 DOT@[44; 45) "."
51 INT_NUMBER@[45; 46) "0"
52 ARG_LIST@[46; 48)
53 L_PAREN@[46; 47) "("
54 R_PAREN@[47; 48) ")"
55 DOT@[48; 49) "."
56 AWAIT_KW@[49; 54) "await"
57 QUESTION@[54; 55) "?"
58 DOT@[55; 56) "."
59 NAME_REF@[56; 61)
60 IDENT@[56; 61) "hello"
61 ARG_LIST@[61; 63)
62 L_PAREN@[61; 62) "("
63 R_PAREN@[62; 63) ")"
64 SEMI@[63; 64) ";"
65 WHITESPACE@[64; 65) "\n"
66 R_CURLY@[65; 66) "}"
67 WHITESPACE@[66; 67) "\n"