aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_parser/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_parser/src')
-rw-r--r--crates/ra_parser/src/grammar/items.rs29
1 files changed, 28 insertions, 1 deletions
diff --git a/crates/ra_parser/src/grammar/items.rs b/crates/ra_parser/src/grammar/items.rs
index e85147e9e..424d0476d 100644
--- a/crates/ra_parser/src/grammar/items.rs
+++ b/crates/ra_parser/src/grammar/items.rs
@@ -103,7 +103,21 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Resul
103 p.bump_remap(T![auto]); 103 p.bump_remap(T![auto]);
104 has_mods = true; 104 has_mods = true;
105 } 105 }
106 if p.at(IDENT) && p.at_contextual_kw("default") && p.nth(1) == T![impl] { 106
107 if p.at(IDENT)
108 && p.at_contextual_kw("default")
109 && (match p.nth(1) {
110 T![impl] => true,
111 T![fn] | T![type] => {
112 if let ItemFlavor::Mod = flavor {
113 true
114 } else {
115 false
116 }
117 }
118 _ => false,
119 })
120 {
107 p.bump_remap(T![default]); 121 p.bump_remap(T![default]);
108 has_mods = true; 122 has_mods = true;
109 } 123 }
@@ -163,12 +177,25 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Resul
163 // test default_impl 177 // test default_impl
164 // default impl Foo {} 178 // default impl Foo {}
165 179
180 // test_err default_fn_type
181 // trait T {
182 // default type T = Bar;
183 // default fn foo() {}
184 // }
185
186 // test default_fn_type
187 // impl T for Foo {
188 // default type T = Bar;
189 // default fn foo() {}
190 // }
191
166 // test unsafe_default_impl 192 // test unsafe_default_impl
167 // unsafe default impl Foo {} 193 // unsafe default impl Foo {}
168 T![impl] => { 194 T![impl] => {
169 traits::impl_block(p); 195 traits::impl_block(p);
170 m.complete(p, IMPL_BLOCK); 196 m.complete(p, IMPL_BLOCK);
171 } 197 }
198
172 // test existential_type 199 // test existential_type
173 // existential type Foo: Fn() -> usize; 200 // existential type Foo: Fn() -> usize;
174 T![type] => { 201 T![type] => {