diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-03-10 17:37:41 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-03-10 17:37:41 +0000 |
commit | f96df105ea6d27f295cc1c0a6cdb6c50979f67ed (patch) | |
tree | a1bb4699afbd53d1ccbfd3585fa15169f971571c /crates/ra_parser | |
parent | 543f2ec8f63ca39182c2c33cbfd093bc008560e7 (diff) | |
parent | cc9721996c4680e257db76aafea12a9565196d92 (diff) |
Merge #956
956: Add async keyword r=c410-f3r a=c410-f3r
Fixes #954.
Co-authored-by: Caio <[email protected]>
Diffstat (limited to 'crates/ra_parser')
-rw-r--r-- | crates/ra_parser/src/grammar/expressions/atom.rs | 5 | ||||
-rw-r--r-- | crates/ra_parser/src/grammar/items.rs | 11 | ||||
-rw-r--r-- | crates/ra_parser/src/syntax_kind/generated.rs | 4 |
3 files changed, 19 insertions, 1 deletions
diff --git a/crates/ra_parser/src/grammar/expressions/atom.rs b/crates/ra_parser/src/grammar/expressions/atom.rs index 9f282c74d..53bb26c5f 100644 --- a/crates/ra_parser/src/grammar/expressions/atom.rs +++ b/crates/ra_parser/src/grammar/expressions/atom.rs | |||
@@ -93,6 +93,11 @@ pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMar | |||
93 | } | 93 | } |
94 | } | 94 | } |
95 | 95 | ||
96 | ASYNC_KW if la == L_CURLY => { | ||
97 | let m = p.start(); | ||
98 | p.bump(); | ||
99 | block_expr(p, Some(m)) | ||
100 | } | ||
96 | MATCH_KW => match_expr(p), | 101 | MATCH_KW => match_expr(p), |
97 | UNSAFE_KW if la == L_CURLY => { | 102 | UNSAFE_KW if la == L_CURLY => { |
98 | let m = p.start(); | 103 | let m = p.start(); |
diff --git a/crates/ra_parser/src/grammar/items.rs b/crates/ra_parser/src/grammar/items.rs index ab9d2de90..a057c8167 100644 --- a/crates/ra_parser/src/grammar/items.rs +++ b/crates/ra_parser/src/grammar/items.rs | |||
@@ -86,9 +86,15 @@ pub(super) fn maybe_item(p: &mut Parser, flavor: ItemFlavor) -> MaybeItem { | |||
86 | } | 86 | } |
87 | 87 | ||
88 | let mut has_mods = false; | 88 | let mut has_mods = false; |
89 | |||
89 | // modifiers | 90 | // modifiers |
91 | // test_err async_without_semicolon | ||
92 | // fn foo() { let _ = async {} } | ||
90 | has_mods |= p.eat(CONST_KW); | 93 | has_mods |= p.eat(CONST_KW); |
91 | 94 | if p.at(ASYNC_KW) && p.nth(1) != L_CURLY { | |
95 | p.eat(ASYNC_KW); | ||
96 | has_mods = true; | ||
97 | } | ||
92 | // test_err unsafe_block_in_mod | 98 | // test_err unsafe_block_in_mod |
93 | // fn foo(){} unsafe { } fn bar(){} | 99 | // fn foo(){} unsafe { } fn bar(){} |
94 | if p.at(UNSAFE_KW) && p.nth(1) != L_CURLY { | 100 | if p.at(UNSAFE_KW) && p.nth(1) != L_CURLY { |
@@ -110,6 +116,9 @@ pub(super) fn maybe_item(p: &mut Parser, flavor: ItemFlavor) -> MaybeItem { | |||
110 | 116 | ||
111 | // items | 117 | // items |
112 | let kind = match p.current() { | 118 | let kind = match p.current() { |
119 | // test async_fn | ||
120 | // async fn foo() {} | ||
121 | |||
113 | // test extern_fn | 122 | // test extern_fn |
114 | // extern fn foo() {} | 123 | // extern fn foo() {} |
115 | 124 | ||
diff --git a/crates/ra_parser/src/syntax_kind/generated.rs b/crates/ra_parser/src/syntax_kind/generated.rs index 0eed44ecf..03247ae38 100644 --- a/crates/ra_parser/src/syntax_kind/generated.rs +++ b/crates/ra_parser/src/syntax_kind/generated.rs | |||
@@ -66,6 +66,7 @@ pub enum SyntaxKind { | |||
66 | SHR, | 66 | SHR, |
67 | SHLEQ, | 67 | SHLEQ, |
68 | SHREQ, | 68 | SHREQ, |
69 | ASYNC_KW, | ||
69 | USE_KW, | 70 | USE_KW, |
70 | FN_KW, | 71 | FN_KW, |
71 | STRUCT_KW, | 72 | STRUCT_KW, |
@@ -233,6 +234,7 @@ use self::SyntaxKind::*; | |||
233 | impl SyntaxKind { | 234 | impl SyntaxKind { |
234 | pub fn is_keyword(self) -> bool { | 235 | pub fn is_keyword(self) -> bool { |
235 | match self { | 236 | match self { |
237 | | ASYNC_KW | ||
236 | | USE_KW | 238 | | USE_KW |
237 | | FN_KW | 239 | | FN_KW |
238 | | STRUCT_KW | 240 | | STRUCT_KW |
@@ -403,6 +405,7 @@ impl SyntaxKind { | |||
403 | SHR => &SyntaxInfo { name: "SHR" }, | 405 | SHR => &SyntaxInfo { name: "SHR" }, |
404 | SHLEQ => &SyntaxInfo { name: "SHLEQ" }, | 406 | SHLEQ => &SyntaxInfo { name: "SHLEQ" }, |
405 | SHREQ => &SyntaxInfo { name: "SHREQ" }, | 407 | SHREQ => &SyntaxInfo { name: "SHREQ" }, |
408 | ASYNC_KW => &SyntaxInfo { name: "ASYNC_KW" }, | ||
406 | USE_KW => &SyntaxInfo { name: "USE_KW" }, | 409 | USE_KW => &SyntaxInfo { name: "USE_KW" }, |
407 | FN_KW => &SyntaxInfo { name: "FN_KW" }, | 410 | FN_KW => &SyntaxInfo { name: "FN_KW" }, |
408 | STRUCT_KW => &SyntaxInfo { name: "STRUCT_KW" }, | 411 | STRUCT_KW => &SyntaxInfo { name: "STRUCT_KW" }, |
@@ -570,6 +573,7 @@ impl SyntaxKind { | |||
570 | } | 573 | } |
571 | pub fn from_keyword(ident: &str) -> Option<SyntaxKind> { | 574 | pub fn from_keyword(ident: &str) -> Option<SyntaxKind> { |
572 | let kw = match ident { | 575 | let kw = match ident { |
576 | "async" => ASYNC_KW, | ||
573 | "use" => USE_KW, | 577 | "use" => USE_KW, |
574 | "fn" => FN_KW, | 578 | "fn" => FN_KW, |
575 | "struct" => STRUCT_KW, | 579 | "struct" => STRUCT_KW, |