aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_parser/src/grammar/items.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_parser/src/grammar/items.rs')
-rw-r--r--crates/ra_parser/src/grammar/items.rs16
1 files changed, 13 insertions, 3 deletions
diff --git a/crates/ra_parser/src/grammar/items.rs b/crates/ra_parser/src/grammar/items.rs
index 7718fbe6a..e85147e9e 100644
--- a/crates/ra_parser/src/grammar/items.rs
+++ b/crates/ra_parser/src/grammar/items.rs
@@ -107,6 +107,10 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Resul
107 p.bump_remap(T![default]); 107 p.bump_remap(T![default]);
108 has_mods = true; 108 has_mods = true;
109 } 109 }
110 if p.at(IDENT) && p.at_contextual_kw("existential") && p.nth(1) == T![type] {
111 p.bump_remap(T![existential]);
112 has_mods = true;
113 }
110 114
111 // items 115 // items
112 match p.current() { 116 match p.current() {
@@ -165,12 +169,17 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Resul
165 traits::impl_block(p); 169 traits::impl_block(p);
166 m.complete(p, IMPL_BLOCK); 170 m.complete(p, IMPL_BLOCK);
167 } 171 }
172 // test existential_type
173 // existential type Foo: Fn() -> usize;
174 T![type] => {
175 type_def(p, m);
176 }
168 _ => { 177 _ => {
169 if !has_visibility && !has_mods { 178 if !has_visibility && !has_mods {
170 return Err(m); 179 return Err(m);
171 } else { 180 } else {
172 if has_mods { 181 if has_mods {
173 p.error("expected fn, trait or impl"); 182 p.error("expected existential, fn, trait or impl");
174 } else { 183 } else {
175 p.error("expected an item"); 184 p.error("expected an item");
176 } 185 }
@@ -187,7 +196,9 @@ fn items_without_modifiers(p: &mut Parser, m: Marker) -> Result<(), Marker> {
187 // test extern_crate 196 // test extern_crate
188 // extern crate foo; 197 // extern crate foo;
189 T![extern] if la == T![crate] => extern_crate_item(p, m), 198 T![extern] if la == T![crate] => extern_crate_item(p, m),
190 T![type] => type_def(p, m), 199 T![type] => {
200 type_def(p, m);
201 }
191 T![mod] => mod_item(p, m), 202 T![mod] => mod_item(p, m),
192 T![struct] => { 203 T![struct] => {
193 // test struct_items 204 // test struct_items
@@ -308,7 +319,6 @@ fn type_def(p: &mut Parser, m: Marker) {
308 // test type_item_where_clause 319 // test type_item_where_clause
309 // type Foo where Foo: Copy = (); 320 // type Foo where Foo: Copy = ();
310 type_params::opt_where_clause(p); 321 type_params::opt_where_clause(p);
311
312 if p.eat(T![=]) { 322 if p.eat(T![=]) {
313 types::type_(p); 323 types::type_(p);
314 } 324 }