aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_parser/src/grammar/expressions.rs12
-rw-r--r--crates/ra_parser/src/syntax_kind/generated.rs7
-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
5 files changed, 93 insertions, 0 deletions
diff --git a/crates/ra_parser/src/grammar/expressions.rs b/crates/ra_parser/src/grammar/expressions.rs
index 298030cb9..3e49e70c7 100644
--- a/crates/ra_parser/src/grammar/expressions.rs
+++ b/crates/ra_parser/src/grammar/expressions.rs
@@ -393,6 +393,18 @@ fn postfix_expr(
393 T![.] if p.nth(1) == IDENT && (p.nth(2) == T!['('] || p.nth(2) == T![::]) => { 393 T![.] if p.nth(1) == IDENT && (p.nth(2) == T!['('] || p.nth(2) == T![::]) => {
394 method_call_expr(p, lhs) 394 method_call_expr(p, lhs)
395 } 395 }
396 T![.] if p.nth(1) == AWAIT_KW => {
397 // test await_expr
398 // fn foo() {
399 // x.await;
400 // x.0.await;
401 // x.0().await?.hello();
402 // }
403 let m = lhs.precede(p);
404 p.bump();
405 p.bump();
406 m.complete(p, AWAIT_EXPR)
407 }
396 T![.] => field_expr(p, lhs), 408 T![.] => field_expr(p, lhs),
397 // test postfix_range 409 // test postfix_range
398 // fn foo() { let x = 1..; } 410 // fn foo() { let x = 1..; }
diff --git a/crates/ra_parser/src/syntax_kind/generated.rs b/crates/ra_parser/src/syntax_kind/generated.rs
index 374fd5aec..4b5abb516 100644
--- a/crates/ra_parser/src/syntax_kind/generated.rs
+++ b/crates/ra_parser/src/syntax_kind/generated.rs
@@ -105,6 +105,7 @@ pub enum SyntaxKind {
105 RETURN_KW, 105 RETURN_KW,
106 TRY_KW, 106 TRY_KW,
107 BOX_KW, 107 BOX_KW,
108 AWAIT_KW,
108 AUTO_KW, 109 AUTO_KW,
109 DEFAULT_KW, 110 DEFAULT_KW,
110 EXISTENTIAL_KW, 111 EXISTENTIAL_KW,
@@ -193,6 +194,7 @@ pub enum SyntaxKind {
193 INDEX_EXPR, 194 INDEX_EXPR,
194 METHOD_CALL_EXPR, 195 METHOD_CALL_EXPR,
195 FIELD_EXPR, 196 FIELD_EXPR,
197 AWAIT_EXPR,
196 TRY_EXPR, 198 TRY_EXPR,
197 CAST_EXPR, 199 CAST_EXPR,
198 REF_EXPR, 200 REF_EXPR,
@@ -338,6 +340,7 @@ macro_rules! T {
338 (return) => { $crate::SyntaxKind::RETURN_KW }; 340 (return) => { $crate::SyntaxKind::RETURN_KW };
339 (try) => { $crate::SyntaxKind::TRY_KW }; 341 (try) => { $crate::SyntaxKind::TRY_KW };
340 (box) => { $crate::SyntaxKind::BOX_KW }; 342 (box) => { $crate::SyntaxKind::BOX_KW };
343 (await) => { $crate::SyntaxKind::AWAIT_KW };
341 (auto) => { $crate::SyntaxKind::AUTO_KW }; 344 (auto) => { $crate::SyntaxKind::AUTO_KW };
342 (default) => { $crate::SyntaxKind::DEFAULT_KW }; 345 (default) => { $crate::SyntaxKind::DEFAULT_KW };
343 (existential) => { $crate::SyntaxKind::EXISTENTIAL_KW }; 346 (existential) => { $crate::SyntaxKind::EXISTENTIAL_KW };
@@ -398,6 +401,7 @@ impl SyntaxKind {
398 | RETURN_KW 401 | RETURN_KW
399 | TRY_KW 402 | TRY_KW
400 | BOX_KW 403 | BOX_KW
404 | AWAIT_KW
401 | AUTO_KW 405 | AUTO_KW
402 | DEFAULT_KW 406 | DEFAULT_KW
403 | EXISTENTIAL_KW 407 | EXISTENTIAL_KW
@@ -572,6 +576,7 @@ impl SyntaxKind {
572 RETURN_KW => &SyntaxInfo { name: "RETURN_KW" }, 576 RETURN_KW => &SyntaxInfo { name: "RETURN_KW" },
573 TRY_KW => &SyntaxInfo { name: "TRY_KW" }, 577 TRY_KW => &SyntaxInfo { name: "TRY_KW" },
574 BOX_KW => &SyntaxInfo { name: "BOX_KW" }, 578 BOX_KW => &SyntaxInfo { name: "BOX_KW" },
579 AWAIT_KW => &SyntaxInfo { name: "AWAIT_KW" },
575 AUTO_KW => &SyntaxInfo { name: "AUTO_KW" }, 580 AUTO_KW => &SyntaxInfo { name: "AUTO_KW" },
576 DEFAULT_KW => &SyntaxInfo { name: "DEFAULT_KW" }, 581 DEFAULT_KW => &SyntaxInfo { name: "DEFAULT_KW" },
577 EXISTENTIAL_KW => &SyntaxInfo { name: "EXISTENTIAL_KW" }, 582 EXISTENTIAL_KW => &SyntaxInfo { name: "EXISTENTIAL_KW" },
@@ -660,6 +665,7 @@ impl SyntaxKind {
660 INDEX_EXPR => &SyntaxInfo { name: "INDEX_EXPR" }, 665 INDEX_EXPR => &SyntaxInfo { name: "INDEX_EXPR" },
661 METHOD_CALL_EXPR => &SyntaxInfo { name: "METHOD_CALL_EXPR" }, 666 METHOD_CALL_EXPR => &SyntaxInfo { name: "METHOD_CALL_EXPR" },
662 FIELD_EXPR => &SyntaxInfo { name: "FIELD_EXPR" }, 667 FIELD_EXPR => &SyntaxInfo { name: "FIELD_EXPR" },
668 AWAIT_EXPR => &SyntaxInfo { name: "AWAIT_EXPR" },
663 TRY_EXPR => &SyntaxInfo { name: "TRY_EXPR" }, 669 TRY_EXPR => &SyntaxInfo { name: "TRY_EXPR" },
664 CAST_EXPR => &SyntaxInfo { name: "CAST_EXPR" }, 670 CAST_EXPR => &SyntaxInfo { name: "CAST_EXPR" },
665 REF_EXPR => &SyntaxInfo { name: "REF_EXPR" }, 671 REF_EXPR => &SyntaxInfo { name: "REF_EXPR" },
@@ -752,6 +758,7 @@ impl SyntaxKind {
752 "return" => RETURN_KW, 758 "return" => RETURN_KW,
753 "try" => TRY_KW, 759 "try" => TRY_KW,
754 "box" => BOX_KW, 760 "box" => BOX_KW,
761 "await" => AWAIT_KW,
755 _ => return None, 762 _ => return None,
756 }; 763 };
757 Some(kw) 764 Some(kw)
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"