Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/parser/src/grammar/items.rs')
-rw-r--r--crates/parser/src/grammar/items.rs22
1 files changed, 13 insertions, 9 deletions
diff --git a/crates/parser/src/grammar/items.rs b/crates/parser/src/grammar/items.rs
index 99bbf47654..d8468ba3cb 100644
--- a/crates/parser/src/grammar/items.rs
+++ b/crates/parser/src/grammar/items.rs
@@ -112,11 +112,22 @@ pub(super) fn opt_item(p: &mut Parser<'_>, m: Marker) -> Result<(), Marker> {
// test_err async_without_semicolon
// fn foo() { let _ = async {} }
- if p.at(T![async]) && !matches!(p.nth(1), T!['{'] | T![move] | T![|]) {
+ if p.at(T![async])
+ && (!matches!(p.nth(1), T!['{'] | T![gen] | T![move] | T![|])
+ || matches!((p.nth(1), p.nth(2)), (T![gen], T![fn])))
+ {
p.eat(T![async]);
has_mods = true;
}
+ // test_err gen_fn
+ // gen fn gen_fn() {}
+ // async gen fn async_gen_fn() {}
+ if p.at(T![gen]) && p.nth(1) == T![fn] {
+ p.eat(T![gen]);
+ has_mods = true;
+ }
+
// test_err unsafe_block_in_mod
// fn foo(){} unsafe { } fn bar(){}
if p.at(T![unsafe]) && p.nth(1) != T!['{'] {
@@ -173,13 +184,6 @@ pub(super) fn opt_item(p: &mut Parser<'_>, m: Marker) -> Result<(), Marker> {
}
}
- // test existential_type
- // existential type Foo: Fn() -> usize;
- if p.at_contextual_kw(T![existential]) && p.nth(1) == T![type] {
- p.bump_remap(T![existential]);
- has_mods = true;
- }
-
// items
match p.current() {
T![fn] => fn_(p, m),
@@ -201,7 +205,7 @@ pub(super) fn opt_item(p: &mut Parser<'_>, m: Marker) -> Result<(), Marker> {
_ if has_visibility || has_mods => {
if has_mods {
- p.error("expected existential, fn, trait or impl");
+ p.error("expected fn, trait or impl");
} else {
p.error("expected an item");
}