aboutsummaryrefslogtreecommitdiff
path: root/crates/parser/src
diff options
context:
space:
mode:
authorArnaud <[email protected]>2021-02-15 17:11:10 +0000
committerArnaud <[email protected]>2021-02-15 17:33:12 +0000
commit95d239da99cb1b7ba60f5f20f6df54e1397a1bca (patch)
treeb50dcd82f35b524ec86b8a95bf64dda9b1e8efd1 /crates/parser/src
parent00d5a9563af9c84cdea9d029a9583be0513cc459 (diff)
Specialization for async traits
Diffstat (limited to 'crates/parser/src')
-rw-r--r--crates/parser/src/grammar/items.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/crates/parser/src/grammar/items.rs b/crates/parser/src/grammar/items.rs
index 1d894e907..adec74ef3 100644
--- a/crates/parser/src/grammar/items.rs
+++ b/crates/parser/src/grammar/items.rs
@@ -83,6 +83,7 @@ pub(super) fn item_or_macro(p: &mut Parser, stop_on_r_curly: bool) {
83 } 83 }
84} 84}
85 85
86/// Try to parse an item, completing `m` in case of success.
86pub(super) fn maybe_item(p: &mut Parser, m: Marker) -> Result<(), Marker> { 87pub(super) fn maybe_item(p: &mut Parser, m: Marker) -> Result<(), Marker> {
87 // test_err pub_expr 88 // test_err pub_expr
88 // fn foo() { pub 92; } 89 // fn foo() { pub 92; }
@@ -143,6 +144,33 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker) -> Result<(), Marker> {
143 has_mods = true; 144 has_mods = true;
144 } 145 }
145 } 146 }
147 T![async] => {
148 // test default_async_fn
149 // impl T for Foo {
150 // default async fn foo() {}
151 // }
152
153 // test default_async_unsafe_fn
154 // impl T for Foo {
155 // default async unsafe fn foo() {}
156 // }
157 let mut maybe_fn = p.nth(2);
158 let is_unsafe = if matches!(maybe_fn, T![unsafe]) {
159 maybe_fn = p.nth(3);
160 true
161 } else {
162 false
163 };
164
165 if matches!(maybe_fn, T![fn]) {
166 p.bump_remap(T![default]);
167 p.bump(T![async]);
168 if is_unsafe {
169 p.bump(T![unsafe])
170 }
171 has_mods = true;
172 }
173 }
146 _ => (), 174 _ => (),
147 } 175 }
148 } 176 }