diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-06-24 11:10:05 +0100 |
---|---|---|
committer | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-06-24 11:10:05 +0100 |
commit | 67ecc88f664818cf04729286afa10ba70ad1a9dd (patch) | |
tree | e43d2e116367c76fdd78fca58ae752aafd72f1f2 /crates/ra_parser | |
parent | b34f65bcedadf2bb8fb738711a01be9c825c98c9 (diff) | |
parent | d04473accb1a22abdb2262d0e8954beaf28ae364 (diff) |
Merge #1415
1415: fix: specialization r=matklad a=csmoe
Closes #1402
r? @matklad
Co-authored-by: csmoe <[email protected]>
Diffstat (limited to 'crates/ra_parser')
-rw-r--r-- | crates/ra_parser/src/grammar/items.rs | 29 |
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] => { |