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.rs38
1 files changed, 19 insertions, 19 deletions
diff --git a/crates/parser/src/grammar/items.rs b/crates/parser/src/grammar/items.rs
index c5c6e04dd4..88a4397232 100644
--- a/crates/parser/src/grammar/items.rs
+++ b/crates/parser/src/grammar/items.rs
@@ -119,6 +119,25 @@ pub(super) fn opt_item(p: &mut Parser<'_>, m: Marker, is_in_extern: bool) -> Res
let mut has_mods = false;
let mut has_extern = false;
+ if p.at(T![impl])
+ && p.nth(1) == T!['(']
+ && ((matches!(p.nth(2), T![crate] | T![super] | T![self]) && p.nth(3) == T![')'])
+ || p.nth(2) == T![in])
+ {
+ // test impl_restrictions
+ // pub impl(crate) unsafe trait Foo {}
+ // impl(in super::bar) trait Bar {}
+ // impl () {}
+ // impl (i32) {}
+ let m = p.start();
+ p.bump(T![impl]);
+ if !opt_visibility_inner(p, false) {
+ p.error("expected an impl restriction");
+ }
+ m.complete(p, IMPL_RESTRICTION);
+ has_mods = true;
+ }
+
// modifiers
if p.at(T![const]) && p.nth(1) != T!['{'] {
p.eat(T![const]);
@@ -167,25 +186,6 @@ pub(super) fn opt_item(p: &mut Parser<'_>, m: Marker, is_in_extern: bool) -> Res
has_mods = true;
}
- if p.at(T![impl])
- && p.nth(1) == T!['(']
- && ((matches!(p.nth(2), T![crate] | T![super] | T![self]) && p.nth(3) == T![')'])
- || p.nth(2) == T![in])
- {
- // test impl_restrictions
- // pub unsafe impl(crate) trait Foo {}
- // impl(in super::bar) trait Bar {}
- // impl () {}
- // impl (i32) {}
- let m = p.start();
- p.bump(T![impl]);
- if !opt_visibility_inner(p, false) {
- p.error("expected an impl restriction");
- }
- m.complete(p, IMPL_RESTRICTION);
- has_mods = true;
- }
-
// test default_item
// default impl T for Foo {}
if p.at_contextual_kw(T![default]) {