diff options
Diffstat (limited to 'crates/parser/src/grammar/params.rs')
-rw-r--r-- | crates/parser/src/grammar/params.rs | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/crates/parser/src/grammar/params.rs b/crates/parser/src/grammar/params.rs index 2d006a1d5..6a98d7368 100644 --- a/crates/parser/src/grammar/params.rs +++ b/crates/parser/src/grammar/params.rs | |||
@@ -156,7 +156,7 @@ fn variadic_param(p: &mut Parser) -> bool { | |||
156 | fn opt_self_param(p: &mut Parser, m: Marker) { | 156 | fn opt_self_param(p: &mut Parser, m: Marker) { |
157 | if p.at(T![self]) || p.at(T![mut]) && p.nth(1) == T![self] { | 157 | if p.at(T![self]) || p.at(T![mut]) && p.nth(1) == T![self] { |
158 | p.eat(T![mut]); | 158 | p.eat(T![mut]); |
159 | p.eat(T![self]); | 159 | self_as_name(p); |
160 | // test arb_self_types | 160 | // test arb_self_types |
161 | // impl S { | 161 | // impl S { |
162 | // fn a(self: &Self) {} | 162 | // fn a(self: &Self) {} |
@@ -169,24 +169,29 @@ fn opt_self_param(p: &mut Parser, m: Marker) { | |||
169 | let la1 = p.nth(1); | 169 | let la1 = p.nth(1); |
170 | let la2 = p.nth(2); | 170 | let la2 = p.nth(2); |
171 | let la3 = p.nth(3); | 171 | let la3 = p.nth(3); |
172 | let mut n_toks = match (p.current(), la1, la2, la3) { | 172 | if !matches!((p.current(), la1, la2, la3), |
173 | (T![&], T![self], _, _) => 2, | 173 | (T![&], T![self], _, _) |
174 | (T![&], T![mut], T![self], _) => 3, | 174 | | (T![&], T![mut], T![self], _) |
175 | (T![&], LIFETIME_IDENT, T![self], _) => 3, | 175 | | (T![&], LIFETIME_IDENT, T![self], _) |
176 | (T![&], LIFETIME_IDENT, T![mut], T![self]) => 4, | 176 | | (T![&], LIFETIME_IDENT, T![mut], T![self]) |
177 | _ => return m.abandon(p), | 177 | ) { |
178 | }; | 178 | return m.abandon(p); |
179 | p.bump_any(); | 179 | } |
180 | p.bump(T![&]); | ||
180 | if p.at(LIFETIME_IDENT) { | 181 | if p.at(LIFETIME_IDENT) { |
181 | lifetime(p); | 182 | lifetime(p); |
182 | n_toks -= 1; | ||
183 | } | ||
184 | for _ in 1..n_toks { | ||
185 | p.bump_any(); | ||
186 | } | 183 | } |
184 | p.eat(T![mut]); | ||
185 | self_as_name(p); | ||
187 | } | 186 | } |
188 | m.complete(p, SELF_PARAM); | 187 | m.complete(p, SELF_PARAM); |
189 | if !p.at(T![')']) { | 188 | if !p.at(T![')']) { |
190 | p.expect(T![,]); | 189 | p.expect(T![,]); |
191 | } | 190 | } |
192 | } | 191 | } |
192 | |||
193 | fn self_as_name(p: &mut Parser) { | ||
194 | let m = p.start(); | ||
195 | p.bump(T![self]); | ||
196 | m.complete(p, NAME); | ||
197 | } | ||