diff options
-rw-r--r-- | crates/ra_parser/src/grammar.rs | 40 | ||||
-rw-r--r-- | crates/ra_parser/src/grammar/attributes.rs | 4 | ||||
-rw-r--r-- | crates/ra_parser/src/grammar/expressions.rs | 38 | ||||
-rw-r--r-- | crates/ra_parser/src/grammar/expressions/atom.rs | 36 | ||||
-rw-r--r-- | crates/ra_parser/src/grammar/items.rs | 20 | ||||
-rw-r--r-- | crates/ra_parser/src/grammar/items/consts.rs | 2 | ||||
-rw-r--r-- | crates/ra_parser/src/grammar/items/nominal.rs | 12 | ||||
-rw-r--r-- | crates/ra_parser/src/grammar/items/traits.rs | 8 | ||||
-rw-r--r-- | crates/ra_parser/src/grammar/items/use_item.rs | 16 | ||||
-rw-r--r-- | crates/ra_parser/src/grammar/params.rs | 4 | ||||
-rw-r--r-- | crates/ra_parser/src/grammar/paths.rs | 4 | ||||
-rw-r--r-- | crates/ra_parser/src/grammar/patterns.rs | 22 | ||||
-rw-r--r-- | crates/ra_parser/src/grammar/type_args.rs | 10 | ||||
-rw-r--r-- | crates/ra_parser/src/grammar/type_params.rs | 18 | ||||
-rw-r--r-- | crates/ra_parser/src/grammar/types.rs | 24 | ||||
-rw-r--r-- | crates/ra_parser/src/parser.rs | 12 |
16 files changed, 138 insertions, 132 deletions
diff --git a/crates/ra_parser/src/grammar.rs b/crates/ra_parser/src/grammar.rs index a2ad580bc..4e6f2f558 100644 --- a/crates/ra_parser/src/grammar.rs +++ b/crates/ra_parser/src/grammar.rs | |||
@@ -93,12 +93,12 @@ pub(crate) mod fragments { | |||
93 | // https://doc.rust-lang.org/reference/paths.html#simple-paths | 93 | // https://doc.rust-lang.org/reference/paths.html#simple-paths |
94 | // The start of an meta must be a simple path | 94 | // The start of an meta must be a simple path |
95 | match p.current() { | 95 | match p.current() { |
96 | IDENT | T![::] | T![super] | T![self] | T![crate] => p.bump(), | 96 | IDENT | T![::] | T![super] | T![self] | T![crate] => p.bump_any(), |
97 | T![=] => { | 97 | T![=] => { |
98 | p.bump(); | 98 | p.bump_any(); |
99 | match p.current() { | 99 | match p.current() { |
100 | c if c.is_literal() => p.bump(), | 100 | c if c.is_literal() => p.bump_any(), |
101 | T![true] | T![false] => p.bump(), | 101 | T![true] | T![false] => p.bump_any(), |
102 | _ => {} | 102 | _ => {} |
103 | } | 103 | } |
104 | break; | 104 | break; |
@@ -126,7 +126,7 @@ pub(crate) mod fragments { | |||
126 | 126 | ||
127 | while !p.at(EOF) { | 127 | while !p.at(EOF) { |
128 | if p.at(T![;]) { | 128 | if p.at(T![;]) { |
129 | p.bump(); | 129 | p.bump(T![;]); |
130 | continue; | 130 | continue; |
131 | } | 131 | } |
132 | 132 | ||
@@ -179,7 +179,7 @@ fn opt_visibility(p: &mut Parser) -> bool { | |||
179 | match p.current() { | 179 | match p.current() { |
180 | T![pub] => { | 180 | T![pub] => { |
181 | let m = p.start(); | 181 | let m = p.start(); |
182 | p.bump(); | 182 | p.bump(T![pub]); |
183 | if p.at(T!['(']) { | 183 | if p.at(T!['(']) { |
184 | match p.nth(1) { | 184 | match p.nth(1) { |
185 | // test crate_visibility | 185 | // test crate_visibility |
@@ -188,13 +188,13 @@ fn opt_visibility(p: &mut Parser) -> bool { | |||
188 | // pub(self) struct S; | 188 | // pub(self) struct S; |
189 | // pub(self) struct S; | 189 | // pub(self) struct S; |
190 | T![crate] | T![self] | T![super] => { | 190 | T![crate] | T![self] | T![super] => { |
191 | p.bump(); | 191 | p.bump_any(); |
192 | p.bump(); | 192 | p.bump_any(); |
193 | p.expect(T![')']); | 193 | p.expect(T![')']); |
194 | } | 194 | } |
195 | T![in] => { | 195 | T![in] => { |
196 | p.bump(); | 196 | p.bump_any(); |
197 | p.bump(); | 197 | p.bump_any(); |
198 | paths::use_path(p); | 198 | paths::use_path(p); |
199 | p.expect(T![')']); | 199 | p.expect(T![')']); |
200 | } | 200 | } |
@@ -212,7 +212,7 @@ fn opt_visibility(p: &mut Parser) -> bool { | |||
212 | // fn foo() { crate::foo(); } | 212 | // fn foo() { crate::foo(); } |
213 | T![crate] if p.nth(1) != T![::] => { | 213 | T![crate] if p.nth(1) != T![::] => { |
214 | let m = p.start(); | 214 | let m = p.start(); |
215 | p.bump(); | 215 | p.bump_any(); |
216 | m.complete(p, VISIBILITY); | 216 | m.complete(p, VISIBILITY); |
217 | } | 217 | } |
218 | _ => return false, | 218 | _ => return false, |
@@ -223,7 +223,7 @@ fn opt_visibility(p: &mut Parser) -> bool { | |||
223 | fn opt_alias(p: &mut Parser) { | 223 | fn opt_alias(p: &mut Parser) { |
224 | if p.at(T![as]) { | 224 | if p.at(T![as]) { |
225 | let m = p.start(); | 225 | let m = p.start(); |
226 | p.bump(); | 226 | p.bump_any(); |
227 | if !p.eat(T![_]) { | 227 | if !p.eat(T![_]) { |
228 | name(p); | 228 | name(p); |
229 | } | 229 | } |
@@ -234,9 +234,9 @@ fn opt_alias(p: &mut Parser) { | |||
234 | fn abi(p: &mut Parser) { | 234 | fn abi(p: &mut Parser) { |
235 | assert!(p.at(T![extern])); | 235 | assert!(p.at(T![extern])); |
236 | let abi = p.start(); | 236 | let abi = p.start(); |
237 | p.bump(); | 237 | p.bump_any(); |
238 | match p.current() { | 238 | match p.current() { |
239 | STRING | RAW_STRING => p.bump(), | 239 | STRING | RAW_STRING => p.bump_any(), |
240 | _ => (), | 240 | _ => (), |
241 | } | 241 | } |
242 | abi.complete(p, ABI); | 242 | abi.complete(p, ABI); |
@@ -245,7 +245,7 @@ fn abi(p: &mut Parser) { | |||
245 | fn opt_fn_ret_type(p: &mut Parser) -> bool { | 245 | fn opt_fn_ret_type(p: &mut Parser) -> bool { |
246 | if p.at(T![->]) { | 246 | if p.at(T![->]) { |
247 | let m = p.start(); | 247 | let m = p.start(); |
248 | p.bump(); | 248 | p.bump_any(); |
249 | types::type_(p); | 249 | types::type_(p); |
250 | m.complete(p, RET_TYPE); | 250 | m.complete(p, RET_TYPE); |
251 | true | 251 | true |
@@ -257,7 +257,7 @@ fn opt_fn_ret_type(p: &mut Parser) -> bool { | |||
257 | fn name_r(p: &mut Parser, recovery: TokenSet) { | 257 | fn name_r(p: &mut Parser, recovery: TokenSet) { |
258 | if p.at(IDENT) { | 258 | if p.at(IDENT) { |
259 | let m = p.start(); | 259 | let m = p.start(); |
260 | p.bump(); | 260 | p.bump_any(); |
261 | m.complete(p, NAME); | 261 | m.complete(p, NAME); |
262 | } else { | 262 | } else { |
263 | p.err_recover("expected a name", recovery); | 263 | p.err_recover("expected a name", recovery); |
@@ -271,11 +271,11 @@ fn name(p: &mut Parser) { | |||
271 | fn name_ref(p: &mut Parser) { | 271 | fn name_ref(p: &mut Parser) { |
272 | if p.at(IDENT) { | 272 | if p.at(IDENT) { |
273 | let m = p.start(); | 273 | let m = p.start(); |
274 | p.bump(); | 274 | p.bump_any(); |
275 | m.complete(p, NAME_REF); | 275 | m.complete(p, NAME_REF); |
276 | } else if p.at(T![self]) { | 276 | } else if p.at(T![self]) { |
277 | let m = p.start(); | 277 | let m = p.start(); |
278 | p.bump(); | 278 | p.bump_any(); |
279 | m.complete(p, T![self]); | 279 | m.complete(p, T![self]); |
280 | } else { | 280 | } else { |
281 | p.err_and_bump("expected identifier"); | 281 | p.err_and_bump("expected identifier"); |
@@ -285,7 +285,7 @@ fn name_ref(p: &mut Parser) { | |||
285 | fn name_ref_or_index(p: &mut Parser) { | 285 | fn name_ref_or_index(p: &mut Parser) { |
286 | if p.at(IDENT) || p.at(INT_NUMBER) { | 286 | if p.at(IDENT) || p.at(INT_NUMBER) { |
287 | let m = p.start(); | 287 | let m = p.start(); |
288 | p.bump(); | 288 | p.bump_any(); |
289 | m.complete(p, NAME_REF); | 289 | m.complete(p, NAME_REF); |
290 | } else { | 290 | } else { |
291 | p.err_and_bump("expected identifier"); | 291 | p.err_and_bump("expected identifier"); |
@@ -296,7 +296,7 @@ fn error_block(p: &mut Parser, message: &str) { | |||
296 | assert!(p.at(T!['{'])); | 296 | assert!(p.at(T!['{'])); |
297 | let m = p.start(); | 297 | let m = p.start(); |
298 | p.error(message); | 298 | p.error(message); |
299 | p.bump(); | 299 | p.bump_any(); |
300 | expressions::expr_block_contents(p); | 300 | expressions::expr_block_contents(p); |
301 | p.eat(T!['}']); | 301 | p.eat(T!['}']); |
302 | m.complete(p, ERROR); | 302 | m.complete(p, ERROR); |
diff --git a/crates/ra_parser/src/grammar/attributes.rs b/crates/ra_parser/src/grammar/attributes.rs index e97170203..81a363a57 100644 --- a/crates/ra_parser/src/grammar/attributes.rs +++ b/crates/ra_parser/src/grammar/attributes.rs | |||
@@ -15,11 +15,11 @@ pub(super) fn outer_attributes(p: &mut Parser) { | |||
15 | fn attribute(p: &mut Parser, inner: bool) { | 15 | fn attribute(p: &mut Parser, inner: bool) { |
16 | let attr = p.start(); | 16 | let attr = p.start(); |
17 | assert!(p.at(T![#])); | 17 | assert!(p.at(T![#])); |
18 | p.bump(); | 18 | p.bump_any(); |
19 | 19 | ||
20 | if inner { | 20 | if inner { |
21 | assert!(p.at(T![!])); | 21 | assert!(p.at(T![!])); |
22 | p.bump(); | 22 | p.bump_any(); |
23 | } | 23 | } |
24 | 24 | ||
25 | if p.at(T!['[']) { | 25 | if p.at(T!['[']) { |
diff --git a/crates/ra_parser/src/grammar/expressions.rs b/crates/ra_parser/src/grammar/expressions.rs index 855418f1c..30036eb46 100644 --- a/crates/ra_parser/src/grammar/expressions.rs +++ b/crates/ra_parser/src/grammar/expressions.rs | |||
@@ -46,7 +46,7 @@ pub(crate) fn block(p: &mut Parser) { | |||
46 | pub(crate) fn naked_block(p: &mut Parser) { | 46 | pub(crate) fn naked_block(p: &mut Parser) { |
47 | assert!(p.at(T!['{'])); | 47 | assert!(p.at(T!['{'])); |
48 | let m = p.start(); | 48 | let m = p.start(); |
49 | p.bump(); | 49 | p.bump_any(); |
50 | expr_block_contents(p); | 50 | expr_block_contents(p); |
51 | p.expect(T!['}']); | 51 | p.expect(T!['}']); |
52 | m.complete(p, BLOCK); | 52 | m.complete(p, BLOCK); |
@@ -153,7 +153,7 @@ pub(super) fn stmt(p: &mut Parser, with_semi: StmtWithSemi) { | |||
153 | // } | 153 | // } |
154 | fn let_stmt(p: &mut Parser, m: Marker, with_semi: StmtWithSemi) { | 154 | fn let_stmt(p: &mut Parser, m: Marker, with_semi: StmtWithSemi) { |
155 | assert!(p.at(T![let])); | 155 | assert!(p.at(T![let])); |
156 | p.bump(); | 156 | p.bump_any(); |
157 | patterns::pattern(p); | 157 | patterns::pattern(p); |
158 | if p.at(T![:]) { | 158 | if p.at(T![:]) { |
159 | types::ascription(p); | 159 | types::ascription(p); |
@@ -198,7 +198,7 @@ pub(crate) fn expr_block_contents(p: &mut Parser) { | |||
198 | // } | 198 | // } |
199 | 199 | ||
200 | if p.at(T![;]) { | 200 | if p.at(T![;]) { |
201 | p.bump(); | 201 | p.bump_any(); |
202 | continue; | 202 | continue; |
203 | } | 203 | } |
204 | 204 | ||
@@ -309,7 +309,7 @@ fn expr_bp( | |||
309 | } | 309 | } |
310 | let m = lhs.precede(p); | 310 | let m = lhs.precede(p); |
311 | match op { | 311 | match op { |
312 | Op::Simple => p.bump(), | 312 | Op::Simple => p.bump_any(), |
313 | Op::Composite(kind, n) => { | 313 | Op::Composite(kind, n) => { |
314 | p.bump_compound(kind, n); | 314 | p.bump_compound(kind, n); |
315 | } | 315 | } |
@@ -338,7 +338,7 @@ fn lhs( | |||
338 | // } | 338 | // } |
339 | T![&] => { | 339 | T![&] => { |
340 | m = p.start(); | 340 | m = p.start(); |
341 | p.bump(); | 341 | p.bump_any(); |
342 | p.eat(T![mut]); | 342 | p.eat(T![mut]); |
343 | REF_EXPR | 343 | REF_EXPR |
344 | } | 344 | } |
@@ -350,14 +350,14 @@ fn lhs( | |||
350 | // } | 350 | // } |
351 | T![*] | T![!] | T![-] => { | 351 | T![*] | T![!] | T![-] => { |
352 | m = p.start(); | 352 | m = p.start(); |
353 | p.bump(); | 353 | p.bump_any(); |
354 | PREFIX_EXPR | 354 | PREFIX_EXPR |
355 | } | 355 | } |
356 | // test full_range_expr | 356 | // test full_range_expr |
357 | // fn foo() { xs[..]; } | 357 | // fn foo() { xs[..]; } |
358 | T![..] | T![..=] => { | 358 | T![..] | T![..=] => { |
359 | m = p.start(); | 359 | m = p.start(); |
360 | p.bump(); | 360 | p.bump_any(); |
361 | if p.at_ts(EXPR_FIRST) { | 361 | if p.at_ts(EXPR_FIRST) { |
362 | expr_bp(p, r, 2, dollar_lvl); | 362 | expr_bp(p, r, 2, dollar_lvl); |
363 | } | 363 | } |
@@ -410,8 +410,8 @@ fn postfix_expr( | |||
410 | // x.0().await?.hello(); | 410 | // x.0().await?.hello(); |
411 | // } | 411 | // } |
412 | let m = lhs.precede(p); | 412 | let m = lhs.precede(p); |
413 | p.bump(); | 413 | p.bump_any(); |
414 | p.bump(); | 414 | p.bump_any(); |
415 | m.complete(p, AWAIT_EXPR) | 415 | m.complete(p, AWAIT_EXPR) |
416 | } | 416 | } |
417 | T![.] => field_expr(p, lhs), | 417 | T![.] => field_expr(p, lhs), |
@@ -419,7 +419,7 @@ fn postfix_expr( | |||
419 | // fn foo() { let x = 1..; } | 419 | // fn foo() { let x = 1..; } |
420 | T![..] | T![..=] if !EXPR_FIRST.contains(p.nth(1)) => { | 420 | T![..] | T![..=] if !EXPR_FIRST.contains(p.nth(1)) => { |
421 | let m = lhs.precede(p); | 421 | let m = lhs.precede(p); |
422 | p.bump(); | 422 | p.bump_any(); |
423 | m.complete(p, RANGE_EXPR) | 423 | m.complete(p, RANGE_EXPR) |
424 | } | 424 | } |
425 | T![?] => try_expr(p, lhs), | 425 | T![?] => try_expr(p, lhs), |
@@ -453,7 +453,7 @@ fn call_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker { | |||
453 | fn index_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker { | 453 | fn index_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker { |
454 | assert!(p.at(T!['['])); | 454 | assert!(p.at(T!['['])); |
455 | let m = lhs.precede(p); | 455 | let m = lhs.precede(p); |
456 | p.bump(); | 456 | p.bump_any(); |
457 | expr(p); | 457 | expr(p); |
458 | p.expect(T![']']); | 458 | p.expect(T![']']); |
459 | m.complete(p, INDEX_EXPR) | 459 | m.complete(p, INDEX_EXPR) |
@@ -467,7 +467,7 @@ fn index_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker { | |||
467 | fn method_call_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker { | 467 | fn method_call_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker { |
468 | assert!(p.at(T![.]) && p.nth(1) == IDENT && (p.nth(2) == T!['('] || p.nth(2) == T![::])); | 468 | assert!(p.at(T![.]) && p.nth(1) == IDENT && (p.nth(2) == T!['('] || p.nth(2) == T![::])); |
469 | let m = lhs.precede(p); | 469 | let m = lhs.precede(p); |
470 | p.bump(); | 470 | p.bump_any(); |
471 | name_ref(p); | 471 | name_ref(p); |
472 | type_args::opt_type_arg_list(p, true); | 472 | type_args::opt_type_arg_list(p, true); |
473 | if p.at(T!['(']) { | 473 | if p.at(T!['(']) { |
@@ -493,12 +493,12 @@ fn method_call_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker { | |||
493 | fn field_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker { | 493 | fn field_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker { |
494 | assert!(p.at(T![.])); | 494 | assert!(p.at(T![.])); |
495 | let m = lhs.precede(p); | 495 | let m = lhs.precede(p); |
496 | p.bump(); | 496 | p.bump_any(); |
497 | if p.at(IDENT) || p.at(INT_NUMBER) { | 497 | if p.at(IDENT) || p.at(INT_NUMBER) { |
498 | name_ref_or_index(p) | 498 | name_ref_or_index(p) |
499 | } else if p.at(FLOAT_NUMBER) { | 499 | } else if p.at(FLOAT_NUMBER) { |
500 | // FIXME: How to recover and instead parse INT + T![.]? | 500 | // FIXME: How to recover and instead parse INT + T![.]? |
501 | p.bump(); | 501 | p.bump_any(); |
502 | } else { | 502 | } else { |
503 | p.error("expected field name or number") | 503 | p.error("expected field name or number") |
504 | } | 504 | } |
@@ -512,7 +512,7 @@ fn field_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker { | |||
512 | fn try_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker { | 512 | fn try_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker { |
513 | assert!(p.at(T![?])); | 513 | assert!(p.at(T![?])); |
514 | let m = lhs.precede(p); | 514 | let m = lhs.precede(p); |
515 | p.bump(); | 515 | p.bump_any(); |
516 | m.complete(p, TRY_EXPR) | 516 | m.complete(p, TRY_EXPR) |
517 | } | 517 | } |
518 | 518 | ||
@@ -526,7 +526,7 @@ fn try_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker { | |||
526 | fn cast_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker { | 526 | fn cast_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker { |
527 | assert!(p.at(T![as])); | 527 | assert!(p.at(T![as])); |
528 | let m = lhs.precede(p); | 528 | let m = lhs.precede(p); |
529 | p.bump(); | 529 | p.bump_any(); |
530 | // Use type_no_bounds(), because cast expressions are not | 530 | // Use type_no_bounds(), because cast expressions are not |
531 | // allowed to have bounds. | 531 | // allowed to have bounds. |
532 | types::type_no_bounds(p); | 532 | types::type_no_bounds(p); |
@@ -536,7 +536,7 @@ fn cast_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker { | |||
536 | fn arg_list(p: &mut Parser) { | 536 | fn arg_list(p: &mut Parser) { |
537 | assert!(p.at(T!['('])); | 537 | assert!(p.at(T!['('])); |
538 | let m = p.start(); | 538 | let m = p.start(); |
539 | p.bump(); | 539 | p.bump_any(); |
540 | while !p.at(T![')']) && !p.at(EOF) { | 540 | while !p.at(T![')']) && !p.at(EOF) { |
541 | if !p.at_ts(EXPR_FIRST) { | 541 | if !p.at_ts(EXPR_FIRST) { |
542 | p.error("expected expression"); | 542 | p.error("expected expression"); |
@@ -585,7 +585,7 @@ fn path_expr(p: &mut Parser, r: Restrictions) -> (CompletedMarker, BlockLike) { | |||
585 | pub(crate) fn record_field_list(p: &mut Parser) { | 585 | pub(crate) fn record_field_list(p: &mut Parser) { |
586 | assert!(p.at(T!['{'])); | 586 | assert!(p.at(T!['{'])); |
587 | let m = p.start(); | 587 | let m = p.start(); |
588 | p.bump(); | 588 | p.bump_any(); |
589 | while !p.at(EOF) && !p.at(T!['}']) { | 589 | while !p.at(EOF) && !p.at(T!['}']) { |
590 | match p.current() { | 590 | match p.current() { |
591 | // test record_literal_field_with_attr | 591 | // test record_literal_field_with_attr |
@@ -602,7 +602,7 @@ pub(crate) fn record_field_list(p: &mut Parser) { | |||
602 | m.complete(p, RECORD_FIELD); | 602 | m.complete(p, RECORD_FIELD); |
603 | } | 603 | } |
604 | T![..] => { | 604 | T![..] => { |
605 | p.bump(); | 605 | p.bump_any(); |
606 | expr(p); | 606 | expr(p); |
607 | } | 607 | } |
608 | T!['{'] => error_block(p, "expected a field"), | 608 | T!['{'] => error_block(p, "expected a field"), |
diff --git a/crates/ra_parser/src/grammar/expressions/atom.rs b/crates/ra_parser/src/grammar/expressions/atom.rs index ec7f2441d..cea79cf6f 100644 --- a/crates/ra_parser/src/grammar/expressions/atom.rs +++ b/crates/ra_parser/src/grammar/expressions/atom.rs | |||
@@ -31,7 +31,7 @@ pub(crate) fn literal(p: &mut Parser) -> Option<CompletedMarker> { | |||
31 | return None; | 31 | return None; |
32 | } | 32 | } |
33 | let m = p.start(); | 33 | let m = p.start(); |
34 | p.bump(); | 34 | p.bump_any(); |
35 | Some(m.complete(p, LITERAL)) | 35 | Some(m.complete(p, LITERAL)) |
36 | } | 36 | } |
37 | 37 | ||
@@ -100,14 +100,14 @@ pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMar | |||
100 | } | 100 | } |
101 | T![async] if la == T!['{'] || (la == T![move] && p.nth(2) == T!['{']) => { | 101 | T![async] if la == T!['{'] || (la == T![move] && p.nth(2) == T!['{']) => { |
102 | let m = p.start(); | 102 | let m = p.start(); |
103 | p.bump(); | 103 | p.bump_any(); |
104 | p.eat(T![move]); | 104 | p.eat(T![move]); |
105 | block_expr(p, Some(m)) | 105 | block_expr(p, Some(m)) |
106 | } | 106 | } |
107 | T![match] => match_expr(p), | 107 | T![match] => match_expr(p), |
108 | T![unsafe] if la == T!['{'] => { | 108 | T![unsafe] if la == T!['{'] => { |
109 | let m = p.start(); | 109 | let m = p.start(); |
110 | p.bump(); | 110 | p.bump_any(); |
111 | block_expr(p, Some(m)) | 111 | block_expr(p, Some(m)) |
112 | } | 112 | } |
113 | T!['{'] => { | 113 | T!['{'] => { |
@@ -179,7 +179,7 @@ fn tuple_expr(p: &mut Parser) -> CompletedMarker { | |||
179 | fn array_expr(p: &mut Parser) -> CompletedMarker { | 179 | fn array_expr(p: &mut Parser) -> CompletedMarker { |
180 | assert!(p.at(T!['['])); | 180 | assert!(p.at(T!['['])); |
181 | let m = p.start(); | 181 | let m = p.start(); |
182 | p.bump(); | 182 | p.bump_any(); |
183 | if p.eat(T![']']) { | 183 | if p.eat(T![']']) { |
184 | return m.complete(p, ARRAY_EXPR); | 184 | return m.complete(p, ARRAY_EXPR); |
185 | } | 185 | } |
@@ -261,11 +261,11 @@ fn lambda_expr(p: &mut Parser) -> CompletedMarker { | |||
261 | fn if_expr(p: &mut Parser) -> CompletedMarker { | 261 | fn if_expr(p: &mut Parser) -> CompletedMarker { |
262 | assert!(p.at(T![if])); | 262 | assert!(p.at(T![if])); |
263 | let m = p.start(); | 263 | let m = p.start(); |
264 | p.bump(); | 264 | p.bump_any(); |
265 | cond(p); | 265 | cond(p); |
266 | block(p); | 266 | block(p); |
267 | if p.at(T![else]) { | 267 | if p.at(T![else]) { |
268 | p.bump(); | 268 | p.bump_any(); |
269 | if p.at(T![if]) { | 269 | if p.at(T![if]) { |
270 | if_expr(p); | 270 | if_expr(p); |
271 | } else { | 271 | } else { |
@@ -284,8 +284,8 @@ fn if_expr(p: &mut Parser) -> CompletedMarker { | |||
284 | fn label(p: &mut Parser) { | 284 | fn label(p: &mut Parser) { |
285 | assert!(p.at(LIFETIME) && p.nth(1) == T![:]); | 285 | assert!(p.at(LIFETIME) && p.nth(1) == T![:]); |
286 | let m = p.start(); | 286 | let m = p.start(); |
287 | p.bump(); | 287 | p.bump_any(); |
288 | p.bump(); | 288 | p.bump_any(); |
289 | m.complete(p, LABEL); | 289 | m.complete(p, LABEL); |
290 | } | 290 | } |
291 | 291 | ||
@@ -296,7 +296,7 @@ fn label(p: &mut Parser) { | |||
296 | fn loop_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker { | 296 | fn loop_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker { |
297 | assert!(p.at(T![loop])); | 297 | assert!(p.at(T![loop])); |
298 | let m = m.unwrap_or_else(|| p.start()); | 298 | let m = m.unwrap_or_else(|| p.start()); |
299 | p.bump(); | 299 | p.bump_any(); |
300 | block(p); | 300 | block(p); |
301 | m.complete(p, LOOP_EXPR) | 301 | m.complete(p, LOOP_EXPR) |
302 | } | 302 | } |
@@ -309,7 +309,7 @@ fn loop_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker { | |||
309 | fn while_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker { | 309 | fn while_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker { |
310 | assert!(p.at(T![while])); | 310 | assert!(p.at(T![while])); |
311 | let m = m.unwrap_or_else(|| p.start()); | 311 | let m = m.unwrap_or_else(|| p.start()); |
312 | p.bump(); | 312 | p.bump_any(); |
313 | cond(p); | 313 | cond(p); |
314 | block(p); | 314 | block(p); |
315 | m.complete(p, WHILE_EXPR) | 315 | m.complete(p, WHILE_EXPR) |
@@ -322,7 +322,7 @@ fn while_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker { | |||
322 | fn for_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker { | 322 | fn for_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker { |
323 | assert!(p.at(T![for])); | 323 | assert!(p.at(T![for])); |
324 | let m = m.unwrap_or_else(|| p.start()); | 324 | let m = m.unwrap_or_else(|| p.start()); |
325 | p.bump(); | 325 | p.bump_any(); |
326 | patterns::pattern(p); | 326 | patterns::pattern(p); |
327 | p.expect(T![in]); | 327 | p.expect(T![in]); |
328 | expr_no_struct(p); | 328 | expr_no_struct(p); |
@@ -356,7 +356,7 @@ fn cond(p: &mut Parser) { | |||
356 | fn match_expr(p: &mut Parser) -> CompletedMarker { | 356 | fn match_expr(p: &mut Parser) -> CompletedMarker { |
357 | assert!(p.at(T![match])); | 357 | assert!(p.at(T![match])); |
358 | let m = p.start(); | 358 | let m = p.start(); |
359 | p.bump(); | 359 | p.bump_any(); |
360 | expr_no_struct(p); | 360 | expr_no_struct(p); |
361 | if p.at(T!['{']) { | 361 | if p.at(T!['{']) { |
362 | match_arm_list(p); | 362 | match_arm_list(p); |
@@ -452,7 +452,7 @@ fn match_arm(p: &mut Parser) -> BlockLike { | |||
452 | fn match_guard(p: &mut Parser) -> CompletedMarker { | 452 | fn match_guard(p: &mut Parser) -> CompletedMarker { |
453 | assert!(p.at(T![if])); | 453 | assert!(p.at(T![if])); |
454 | let m = p.start(); | 454 | let m = p.start(); |
455 | p.bump(); | 455 | p.bump_any(); |
456 | expr(p); | 456 | expr(p); |
457 | m.complete(p, MATCH_GUARD) | 457 | m.complete(p, MATCH_GUARD) |
458 | } | 458 | } |
@@ -478,7 +478,7 @@ pub(super) fn block_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker { | |||
478 | fn return_expr(p: &mut Parser) -> CompletedMarker { | 478 | fn return_expr(p: &mut Parser) -> CompletedMarker { |
479 | assert!(p.at(T![return])); | 479 | assert!(p.at(T![return])); |
480 | let m = p.start(); | 480 | let m = p.start(); |
481 | p.bump(); | 481 | p.bump_any(); |
482 | if p.at_ts(EXPR_FIRST) { | 482 | if p.at_ts(EXPR_FIRST) { |
483 | expr(p); | 483 | expr(p); |
484 | } | 484 | } |
@@ -495,7 +495,7 @@ fn return_expr(p: &mut Parser) -> CompletedMarker { | |||
495 | fn continue_expr(p: &mut Parser) -> CompletedMarker { | 495 | fn continue_expr(p: &mut Parser) -> CompletedMarker { |
496 | assert!(p.at(T![continue])); | 496 | assert!(p.at(T![continue])); |
497 | let m = p.start(); | 497 | let m = p.start(); |
498 | p.bump(); | 498 | p.bump_any(); |
499 | p.eat(LIFETIME); | 499 | p.eat(LIFETIME); |
500 | m.complete(p, CONTINUE_EXPR) | 500 | m.complete(p, CONTINUE_EXPR) |
501 | } | 501 | } |
@@ -512,7 +512,7 @@ fn continue_expr(p: &mut Parser) -> CompletedMarker { | |||
512 | fn break_expr(p: &mut Parser, r: Restrictions) -> CompletedMarker { | 512 | fn break_expr(p: &mut Parser, r: Restrictions) -> CompletedMarker { |
513 | assert!(p.at(T![break])); | 513 | assert!(p.at(T![break])); |
514 | let m = p.start(); | 514 | let m = p.start(); |
515 | p.bump(); | 515 | p.bump_any(); |
516 | p.eat(LIFETIME); | 516 | p.eat(LIFETIME); |
517 | // test break_ambiguity | 517 | // test break_ambiguity |
518 | // fn foo(){ | 518 | // fn foo(){ |
@@ -534,7 +534,7 @@ fn break_expr(p: &mut Parser, r: Restrictions) -> CompletedMarker { | |||
534 | fn try_block_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker { | 534 | fn try_block_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker { |
535 | assert!(p.at(T![try])); | 535 | assert!(p.at(T![try])); |
536 | let m = m.unwrap_or_else(|| p.start()); | 536 | let m = m.unwrap_or_else(|| p.start()); |
537 | p.bump(); | 537 | p.bump_any(); |
538 | block(p); | 538 | block(p); |
539 | m.complete(p, TRY_EXPR) | 539 | m.complete(p, TRY_EXPR) |
540 | } | 540 | } |
@@ -548,7 +548,7 @@ fn try_block_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker { | |||
548 | fn box_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker { | 548 | fn box_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker { |
549 | assert!(p.at(T![box])); | 549 | assert!(p.at(T![box])); |
550 | let m = m.unwrap_or_else(|| p.start()); | 550 | let m = m.unwrap_or_else(|| p.start()); |
551 | p.bump(); | 551 | p.bump_any(); |
552 | if p.at_ts(EXPR_FIRST) { | 552 | if p.at_ts(EXPR_FIRST) { |
553 | expr(p); | 553 | expr(p); |
554 | } | 554 | } |
diff --git a/crates/ra_parser/src/grammar/items.rs b/crates/ra_parser/src/grammar/items.rs index b4327b78f..f27cc85ff 100644 --- a/crates/ra_parser/src/grammar/items.rs +++ b/crates/ra_parser/src/grammar/items.rs | |||
@@ -64,7 +64,7 @@ pub(super) fn item_or_macro(p: &mut Parser, stop_on_r_curly: bool, flavor: ItemF | |||
64 | } else if p.at(T!['}']) && !stop_on_r_curly { | 64 | } else if p.at(T!['}']) && !stop_on_r_curly { |
65 | let e = p.start(); | 65 | let e = p.start(); |
66 | p.error("unmatched `}`"); | 66 | p.error("unmatched `}`"); |
67 | p.bump(); | 67 | p.bump_any(); |
68 | e.complete(p, ERROR); | 68 | e.complete(p, ERROR); |
69 | } else if !p.at(EOF) && !p.at(T!['}']) { | 69 | } else if !p.at(EOF) && !p.at(T!['}']) { |
70 | p.err_and_bump("expected an item"); | 70 | p.err_and_bump("expected an item"); |
@@ -276,9 +276,9 @@ fn items_without_modifiers(p: &mut Parser, m: Marker) -> Result<(), Marker> { | |||
276 | 276 | ||
277 | fn extern_crate_item(p: &mut Parser, m: Marker) { | 277 | fn extern_crate_item(p: &mut Parser, m: Marker) { |
278 | assert!(p.at(T![extern])); | 278 | assert!(p.at(T![extern])); |
279 | p.bump(); | 279 | p.bump_any(); |
280 | assert!(p.at(T![crate])); | 280 | assert!(p.at(T![crate])); |
281 | p.bump(); | 281 | p.bump_any(); |
282 | name_ref(p); | 282 | name_ref(p); |
283 | opt_alias(p); | 283 | opt_alias(p); |
284 | p.expect(T![;]); | 284 | p.expect(T![;]); |
@@ -288,7 +288,7 @@ fn extern_crate_item(p: &mut Parser, m: Marker) { | |||
288 | pub(crate) fn extern_item_list(p: &mut Parser) { | 288 | pub(crate) fn extern_item_list(p: &mut Parser) { |
289 | assert!(p.at(T!['{'])); | 289 | assert!(p.at(T!['{'])); |
290 | let m = p.start(); | 290 | let m = p.start(); |
291 | p.bump(); | 291 | p.bump_any(); |
292 | mod_contents(p, true); | 292 | mod_contents(p, true); |
293 | p.expect(T!['}']); | 293 | p.expect(T!['}']); |
294 | m.complete(p, EXTERN_ITEM_LIST); | 294 | m.complete(p, EXTERN_ITEM_LIST); |
@@ -296,7 +296,7 @@ pub(crate) fn extern_item_list(p: &mut Parser) { | |||
296 | 296 | ||
297 | fn fn_def(p: &mut Parser, flavor: ItemFlavor) { | 297 | fn fn_def(p: &mut Parser, flavor: ItemFlavor) { |
298 | assert!(p.at(T![fn])); | 298 | assert!(p.at(T![fn])); |
299 | p.bump(); | 299 | p.bump_any(); |
300 | 300 | ||
301 | name_r(p, ITEM_RECOVERY_SET); | 301 | name_r(p, ITEM_RECOVERY_SET); |
302 | // test function_type_params | 302 | // test function_type_params |
@@ -323,7 +323,7 @@ fn fn_def(p: &mut Parser, flavor: ItemFlavor) { | |||
323 | // test fn_decl | 323 | // test fn_decl |
324 | // trait T { fn foo(); } | 324 | // trait T { fn foo(); } |
325 | if p.at(T![;]) { | 325 | if p.at(T![;]) { |
326 | p.bump(); | 326 | p.bump_any(); |
327 | } else { | 327 | } else { |
328 | expressions::block(p) | 328 | expressions::block(p) |
329 | } | 329 | } |
@@ -333,7 +333,7 @@ fn fn_def(p: &mut Parser, flavor: ItemFlavor) { | |||
333 | // type Foo = Bar; | 333 | // type Foo = Bar; |
334 | fn type_def(p: &mut Parser, m: Marker) { | 334 | fn type_def(p: &mut Parser, m: Marker) { |
335 | assert!(p.at(T![type])); | 335 | assert!(p.at(T![type])); |
336 | p.bump(); | 336 | p.bump_any(); |
337 | 337 | ||
338 | name(p); | 338 | name(p); |
339 | 339 | ||
@@ -357,7 +357,7 @@ fn type_def(p: &mut Parser, m: Marker) { | |||
357 | 357 | ||
358 | pub(crate) fn mod_item(p: &mut Parser, m: Marker) { | 358 | pub(crate) fn mod_item(p: &mut Parser, m: Marker) { |
359 | assert!(p.at(T![mod])); | 359 | assert!(p.at(T![mod])); |
360 | p.bump(); | 360 | p.bump_any(); |
361 | 361 | ||
362 | name(p); | 362 | name(p); |
363 | if p.at(T!['{']) { | 363 | if p.at(T!['{']) { |
@@ -371,7 +371,7 @@ pub(crate) fn mod_item(p: &mut Parser, m: Marker) { | |||
371 | pub(crate) fn mod_item_list(p: &mut Parser) { | 371 | pub(crate) fn mod_item_list(p: &mut Parser) { |
372 | assert!(p.at(T!['{'])); | 372 | assert!(p.at(T!['{'])); |
373 | let m = p.start(); | 373 | let m = p.start(); |
374 | p.bump(); | 374 | p.bump_any(); |
375 | mod_contents(p, true); | 375 | mod_contents(p, true); |
376 | p.expect(T!['}']); | 376 | p.expect(T!['}']); |
377 | m.complete(p, ITEM_LIST); | 377 | m.complete(p, ITEM_LIST); |
@@ -412,7 +412,7 @@ pub(crate) fn token_tree(p: &mut Parser) { | |||
412 | _ => unreachable!(), | 412 | _ => unreachable!(), |
413 | }; | 413 | }; |
414 | let m = p.start(); | 414 | let m = p.start(); |
415 | p.bump(); | 415 | p.bump_any(); |
416 | while !p.at(EOF) && !p.at(closing_paren_kind) { | 416 | while !p.at(EOF) && !p.at(closing_paren_kind) { |
417 | match p.current() { | 417 | match p.current() { |
418 | T!['{'] | T!['('] | T!['['] => token_tree(p), | 418 | T!['{'] | T!['('] | T!['['] => token_tree(p), |
diff --git a/crates/ra_parser/src/grammar/items/consts.rs b/crates/ra_parser/src/grammar/items/consts.rs index b4908ebba..e11546333 100644 --- a/crates/ra_parser/src/grammar/items/consts.rs +++ b/crates/ra_parser/src/grammar/items/consts.rs | |||
@@ -10,7 +10,7 @@ pub(super) fn const_def(p: &mut Parser, m: Marker) { | |||
10 | 10 | ||
11 | fn const_or_static(p: &mut Parser, m: Marker, kw: SyntaxKind, def: SyntaxKind) { | 11 | fn const_or_static(p: &mut Parser, m: Marker, kw: SyntaxKind, def: SyntaxKind) { |
12 | assert!(p.at(kw)); | 12 | assert!(p.at(kw)); |
13 | p.bump(); | 13 | p.bump_any(); |
14 | p.eat(T![mut]); // FIXME: validator to forbid const mut | 14 | p.eat(T![mut]); // FIXME: validator to forbid const mut |
15 | name(p); | 15 | name(p); |
16 | types::ascription(p); | 16 | types::ascription(p); |
diff --git a/crates/ra_parser/src/grammar/items/nominal.rs b/crates/ra_parser/src/grammar/items/nominal.rs index 54f02c7c9..460acd65e 100644 --- a/crates/ra_parser/src/grammar/items/nominal.rs +++ b/crates/ra_parser/src/grammar/items/nominal.rs | |||
@@ -11,7 +11,7 @@ pub(super) fn struct_def(p: &mut Parser, m: Marker, kind: SyntaxKind) { | |||
11 | type_params::opt_where_clause(p); | 11 | type_params::opt_where_clause(p); |
12 | match p.current() { | 12 | match p.current() { |
13 | T![;] => { | 13 | T![;] => { |
14 | p.bump(); | 14 | p.bump_any(); |
15 | } | 15 | } |
16 | T!['{'] => record_field_def_list(p), | 16 | T!['{'] => record_field_def_list(p), |
17 | _ => { | 17 | _ => { |
@@ -21,7 +21,7 @@ pub(super) fn struct_def(p: &mut Parser, m: Marker, kind: SyntaxKind) { | |||
21 | } | 21 | } |
22 | } | 22 | } |
23 | T![;] if kind == T![struct] => { | 23 | T![;] if kind == T![struct] => { |
24 | p.bump(); | 24 | p.bump_any(); |
25 | } | 25 | } |
26 | T!['{'] => record_field_def_list(p), | 26 | T!['{'] => record_field_def_list(p), |
27 | T!['('] if kind == T![struct] => { | 27 | T!['('] if kind == T![struct] => { |
@@ -44,7 +44,7 @@ pub(super) fn struct_def(p: &mut Parser, m: Marker, kind: SyntaxKind) { | |||
44 | 44 | ||
45 | pub(super) fn enum_def(p: &mut Parser, m: Marker) { | 45 | pub(super) fn enum_def(p: &mut Parser, m: Marker) { |
46 | assert!(p.at(T![enum])); | 46 | assert!(p.at(T![enum])); |
47 | p.bump(); | 47 | p.bump_any(); |
48 | name_r(p, ITEM_RECOVERY_SET); | 48 | name_r(p, ITEM_RECOVERY_SET); |
49 | type_params::opt_type_param_list(p); | 49 | type_params::opt_type_param_list(p); |
50 | type_params::opt_where_clause(p); | 50 | type_params::opt_where_clause(p); |
@@ -59,7 +59,7 @@ pub(super) fn enum_def(p: &mut Parser, m: Marker) { | |||
59 | pub(crate) fn enum_variant_list(p: &mut Parser) { | 59 | pub(crate) fn enum_variant_list(p: &mut Parser) { |
60 | assert!(p.at(T!['{'])); | 60 | assert!(p.at(T!['{'])); |
61 | let m = p.start(); | 61 | let m = p.start(); |
62 | p.bump(); | 62 | p.bump_any(); |
63 | while !p.at(EOF) && !p.at(T!['}']) { | 63 | while !p.at(EOF) && !p.at(T!['}']) { |
64 | if p.at(T!['{']) { | 64 | if p.at(T!['{']) { |
65 | error_block(p, "expected enum variant"); | 65 | error_block(p, "expected enum variant"); |
@@ -73,7 +73,7 @@ pub(crate) fn enum_variant_list(p: &mut Parser) { | |||
73 | T!['{'] => record_field_def_list(p), | 73 | T!['{'] => record_field_def_list(p), |
74 | T!['('] => tuple_field_def_list(p), | 74 | T!['('] => tuple_field_def_list(p), |
75 | T![=] => { | 75 | T![=] => { |
76 | p.bump(); | 76 | p.bump_any(); |
77 | expressions::expr(p); | 77 | expressions::expr(p); |
78 | } | 78 | } |
79 | _ => (), | 79 | _ => (), |
@@ -94,7 +94,7 @@ pub(crate) fn enum_variant_list(p: &mut Parser) { | |||
94 | pub(crate) fn record_field_def_list(p: &mut Parser) { | 94 | pub(crate) fn record_field_def_list(p: &mut Parser) { |
95 | assert!(p.at(T!['{'])); | 95 | assert!(p.at(T!['{'])); |
96 | let m = p.start(); | 96 | let m = p.start(); |
97 | p.bump(); | 97 | p.bump_any(); |
98 | while !p.at(T!['}']) && !p.at(EOF) { | 98 | while !p.at(T!['}']) && !p.at(EOF) { |
99 | if p.at(T!['{']) { | 99 | if p.at(T!['{']) { |
100 | error_block(p, "expected field"); | 100 | error_block(p, "expected field"); |
diff --git a/crates/ra_parser/src/grammar/items/traits.rs b/crates/ra_parser/src/grammar/items/traits.rs index 5fcacfbff..b49221a4b 100644 --- a/crates/ra_parser/src/grammar/items/traits.rs +++ b/crates/ra_parser/src/grammar/items/traits.rs | |||
@@ -5,7 +5,7 @@ use super::*; | |||
5 | // trait X<U: Debug + Display>: Hash + Clone where U: Copy {} | 5 | // trait X<U: Debug + Display>: Hash + Clone where U: Copy {} |
6 | pub(super) fn trait_def(p: &mut Parser) { | 6 | pub(super) fn trait_def(p: &mut Parser) { |
7 | assert!(p.at(T![trait])); | 7 | assert!(p.at(T![trait])); |
8 | p.bump(); | 8 | p.bump_any(); |
9 | name_r(p, ITEM_RECOVERY_SET); | 9 | name_r(p, ITEM_RECOVERY_SET); |
10 | type_params::opt_type_param_list(p); | 10 | type_params::opt_type_param_list(p); |
11 | if p.at(T![:]) { | 11 | if p.at(T![:]) { |
@@ -29,7 +29,7 @@ pub(super) fn trait_def(p: &mut Parser) { | |||
29 | pub(crate) fn trait_item_list(p: &mut Parser) { | 29 | pub(crate) fn trait_item_list(p: &mut Parser) { |
30 | assert!(p.at(T!['{'])); | 30 | assert!(p.at(T!['{'])); |
31 | let m = p.start(); | 31 | let m = p.start(); |
32 | p.bump(); | 32 | p.bump_any(); |
33 | while !p.at(EOF) && !p.at(T!['}']) { | 33 | while !p.at(EOF) && !p.at(T!['}']) { |
34 | if p.at(T!['{']) { | 34 | if p.at(T!['{']) { |
35 | error_block(p, "expected an item"); | 35 | error_block(p, "expected an item"); |
@@ -45,7 +45,7 @@ pub(crate) fn trait_item_list(p: &mut Parser) { | |||
45 | // impl Foo {} | 45 | // impl Foo {} |
46 | pub(super) fn impl_block(p: &mut Parser) { | 46 | pub(super) fn impl_block(p: &mut Parser) { |
47 | assert!(p.at(T![impl])); | 47 | assert!(p.at(T![impl])); |
48 | p.bump(); | 48 | p.bump_any(); |
49 | if choose_type_params_over_qpath(p) { | 49 | if choose_type_params_over_qpath(p) { |
50 | type_params::opt_type_param_list(p); | 50 | type_params::opt_type_param_list(p); |
51 | } | 51 | } |
@@ -78,7 +78,7 @@ pub(super) fn impl_block(p: &mut Parser) { | |||
78 | pub(crate) fn impl_item_list(p: &mut Parser) { | 78 | pub(crate) fn impl_item_list(p: &mut Parser) { |
79 | assert!(p.at(T!['{'])); | 79 | assert!(p.at(T!['{'])); |
80 | let m = p.start(); | 80 | let m = p.start(); |
81 | p.bump(); | 81 | p.bump_any(); |
82 | // test impl_inner_attributes | 82 | // test impl_inner_attributes |
83 | // enum F{} | 83 | // enum F{} |
84 | // impl F { | 84 | // impl F { |
diff --git a/crates/ra_parser/src/grammar/items/use_item.rs b/crates/ra_parser/src/grammar/items/use_item.rs index 83a65e226..7a1693a34 100644 --- a/crates/ra_parser/src/grammar/items/use_item.rs +++ b/crates/ra_parser/src/grammar/items/use_item.rs | |||
@@ -2,7 +2,7 @@ use super::*; | |||
2 | 2 | ||
3 | pub(super) fn use_item(p: &mut Parser, m: Marker) { | 3 | pub(super) fn use_item(p: &mut Parser, m: Marker) { |
4 | assert!(p.at(T![use])); | 4 | assert!(p.at(T![use])); |
5 | p.bump(); | 5 | p.bump_any(); |
6 | use_tree(p); | 6 | use_tree(p); |
7 | p.expect(T![;]); | 7 | p.expect(T![;]); |
8 | m.complete(p, USE_ITEM); | 8 | m.complete(p, USE_ITEM); |
@@ -28,15 +28,15 @@ fn use_tree(p: &mut Parser) { | |||
28 | // use ::*; | 28 | // use ::*; |
29 | // use some::path::{*}; | 29 | // use some::path::{*}; |
30 | // use some::path::{::*}; | 30 | // use some::path::{::*}; |
31 | (T![*], _) => p.bump(), | 31 | (T![*], _) => p.bump_any(), |
32 | (T![::], T![*]) => { | 32 | (T![::], T![*]) => { |
33 | // Parse `use ::*;`, which imports all from the crate root in Rust 2015 | 33 | // Parse `use ::*;`, which imports all from the crate root in Rust 2015 |
34 | // This is invalid inside a use_tree_list, (e.g. `use some::path::{::*}`) | 34 | // This is invalid inside a use_tree_list, (e.g. `use some::path::{::*}`) |
35 | // but still parses and errors later: ('crate root in paths can only be used in start position') | 35 | // but still parses and errors later: ('crate root in paths can only be used in start position') |
36 | // FIXME: Add this error (if not out of scope) | 36 | // FIXME: Add this error (if not out of scope) |
37 | // In Rust 2018, it is always invalid (see above) | 37 | // In Rust 2018, it is always invalid (see above) |
38 | p.bump(); | 38 | p.bump_any(); |
39 | p.bump(); | 39 | p.bump_any(); |
40 | } | 40 | } |
41 | // Open a use tree list | 41 | // Open a use tree list |
42 | // Handles cases such as `use {some::path};` or `{inner::path}` in | 42 | // Handles cases such as `use {some::path};` or `{inner::path}` in |
@@ -49,7 +49,7 @@ fn use_tree(p: &mut Parser) { | |||
49 | // use ::{{{crate::export}}}; // Nonsensical but perfectly legal nestnig | 49 | // use ::{{{crate::export}}}; // Nonsensical but perfectly legal nestnig |
50 | (T!['{'], _) | (T![::], T!['{']) => { | 50 | (T!['{'], _) | (T![::], T!['{']) => { |
51 | if p.at(T![::]) { | 51 | if p.at(T![::]) { |
52 | p.bump(); | 52 | p.bump_any(); |
53 | } | 53 | } |
54 | use_tree_list(p); | 54 | use_tree_list(p); |
55 | } | 55 | } |
@@ -81,10 +81,10 @@ fn use_tree(p: &mut Parser) { | |||
81 | opt_alias(p); | 81 | opt_alias(p); |
82 | } | 82 | } |
83 | T![::] => { | 83 | T![::] => { |
84 | p.bump(); | 84 | p.bump_any(); |
85 | match p.current() { | 85 | match p.current() { |
86 | T![*] => { | 86 | T![*] => { |
87 | p.bump(); | 87 | p.bump_any(); |
88 | } | 88 | } |
89 | // test use_tree_list_after_path | 89 | // test use_tree_list_after_path |
90 | // use crate::{Item}; | 90 | // use crate::{Item}; |
@@ -114,7 +114,7 @@ fn use_tree(p: &mut Parser) { | |||
114 | pub(crate) fn use_tree_list(p: &mut Parser) { | 114 | pub(crate) fn use_tree_list(p: &mut Parser) { |
115 | assert!(p.at(T!['{'])); | 115 | assert!(p.at(T!['{'])); |
116 | let m = p.start(); | 116 | let m = p.start(); |
117 | p.bump(); | 117 | p.bump_any(); |
118 | while !p.at(EOF) && !p.at(T!['}']) { | 118 | while !p.at(EOF) && !p.at(T!['}']) { |
119 | use_tree(p); | 119 | use_tree(p); |
120 | if !p.at(T!['}']) { | 120 | if !p.at(T!['}']) { |
diff --git a/crates/ra_parser/src/grammar/params.rs b/crates/ra_parser/src/grammar/params.rs index 0b09f1874..56e457325 100644 --- a/crates/ra_parser/src/grammar/params.rs +++ b/crates/ra_parser/src/grammar/params.rs | |||
@@ -39,7 +39,7 @@ fn list_(p: &mut Parser, flavor: Flavor) { | |||
39 | let (bra, ket) = if flavor.type_required() { (T!['('], T![')']) } else { (T![|], T![|]) }; | 39 | let (bra, ket) = if flavor.type_required() { (T!['('], T![')']) } else { (T![|], T![|]) }; |
40 | assert!(p.at(bra)); | 40 | assert!(p.at(bra)); |
41 | let m = p.start(); | 41 | let m = p.start(); |
42 | p.bump(); | 42 | p.bump_any(); |
43 | if flavor.type_required() { | 43 | if flavor.type_required() { |
44 | // test self_param_outer_attr | 44 | // test self_param_outer_attr |
45 | // fn f(#[must_use] self) {} | 45 | // fn f(#[must_use] self) {} |
@@ -146,7 +146,7 @@ fn opt_self_param(p: &mut Parser) { | |||
146 | }; | 146 | }; |
147 | m = p.start(); | 147 | m = p.start(); |
148 | for _ in 0..n_toks { | 148 | for _ in 0..n_toks { |
149 | p.bump(); | 149 | p.bump_any(); |
150 | } | 150 | } |
151 | } | 151 | } |
152 | m.complete(p, SELF_PARAM); | 152 | m.complete(p, SELF_PARAM); |
diff --git a/crates/ra_parser/src/grammar/paths.rs b/crates/ra_parser/src/grammar/paths.rs index 28c35a67d..345c93f55 100644 --- a/crates/ra_parser/src/grammar/paths.rs +++ b/crates/ra_parser/src/grammar/paths.rs | |||
@@ -44,7 +44,7 @@ fn path(p: &mut Parser, mode: Mode) { | |||
44 | }; | 44 | }; |
45 | if p.at(T![::]) && !use_tree { | 45 | if p.at(T![::]) && !use_tree { |
46 | let path = qual.precede(p); | 46 | let path = qual.precede(p); |
47 | p.bump(); | 47 | p.bump_any(); |
48 | path_segment(p, mode, false); | 48 | path_segment(p, mode, false); |
49 | let path = path.complete(p, PATH); | 49 | let path = path.complete(p, PATH); |
50 | qual = path; | 50 | qual = path; |
@@ -80,7 +80,7 @@ fn path_segment(p: &mut Parser, mode: Mode, first: bool) { | |||
80 | } | 80 | } |
81 | // test crate_path | 81 | // test crate_path |
82 | // use crate::foo; | 82 | // use crate::foo; |
83 | T![self] | T![super] | T![crate] => p.bump(), | 83 | T![self] | T![super] | T![crate] => p.bump_any(), |
84 | _ => { | 84 | _ => { |
85 | p.err_recover("expected identifier", items::ITEM_RECOVERY_SET); | 85 | p.err_recover("expected identifier", items::ITEM_RECOVERY_SET); |
86 | } | 86 | } |
diff --git a/crates/ra_parser/src/grammar/patterns.rs b/crates/ra_parser/src/grammar/patterns.rs index 32cde7de6..d2f4296f8 100644 --- a/crates/ra_parser/src/grammar/patterns.rs +++ b/crates/ra_parser/src/grammar/patterns.rs | |||
@@ -36,7 +36,7 @@ pub(super) fn pattern_r(p: &mut Parser, recovery_set: TokenSet) { | |||
36 | // } | 36 | // } |
37 | if p.at(T![...]) || p.at(T![..=]) || p.at(T![..]) { | 37 | if p.at(T![...]) || p.at(T![..=]) || p.at(T![..]) { |
38 | let m = lhs.precede(p); | 38 | let m = lhs.precede(p); |
39 | p.bump(); | 39 | p.bump_any(); |
40 | atom_pat(p, recovery_set); | 40 | atom_pat(p, recovery_set); |
41 | m.complete(p, RANGE_PAT); | 41 | m.complete(p, RANGE_PAT); |
42 | } | 42 | } |
@@ -100,7 +100,7 @@ fn literal_pat(p: &mut Parser) -> CompletedMarker { | |||
100 | assert!(is_literal_pat_start(p)); | 100 | assert!(is_literal_pat_start(p)); |
101 | let m = p.start(); | 101 | let m = p.start(); |
102 | if p.at(T![-]) { | 102 | if p.at(T![-]) { |
103 | p.bump(); | 103 | p.bump_any(); |
104 | } | 104 | } |
105 | expressions::literal(p); | 105 | expressions::literal(p); |
106 | m.complete(p, LITERAL_PAT) | 106 | m.complete(p, LITERAL_PAT) |
@@ -140,7 +140,7 @@ fn path_pat(p: &mut Parser) -> CompletedMarker { | |||
140 | // } | 140 | // } |
141 | fn tuple_pat_fields(p: &mut Parser) { | 141 | fn tuple_pat_fields(p: &mut Parser) { |
142 | assert!(p.at(T!['('])); | 142 | assert!(p.at(T!['('])); |
143 | p.bump(); | 143 | p.bump_any(); |
144 | pat_list(p, T![')']); | 144 | pat_list(p, T![')']); |
145 | p.expect(T![')']); | 145 | p.expect(T![')']); |
146 | } | 146 | } |
@@ -155,10 +155,10 @@ fn tuple_pat_fields(p: &mut Parser) { | |||
155 | fn record_field_pat_list(p: &mut Parser) { | 155 | fn record_field_pat_list(p: &mut Parser) { |
156 | assert!(p.at(T!['{'])); | 156 | assert!(p.at(T!['{'])); |
157 | let m = p.start(); | 157 | let m = p.start(); |
158 | p.bump(); | 158 | p.bump_any(); |
159 | while !p.at(EOF) && !p.at(T!['}']) { | 159 | while !p.at(EOF) && !p.at(T!['}']) { |
160 | match p.current() { | 160 | match p.current() { |
161 | T![..] => p.bump(), | 161 | T![..] => p.bump_any(), |
162 | IDENT if p.nth(1) == T![:] => record_field_pat(p), | 162 | IDENT if p.nth(1) == T![:] => record_field_pat(p), |
163 | T!['{'] => error_block(p, "expected ident"), | 163 | T!['{'] => error_block(p, "expected ident"), |
164 | T![box] => { | 164 | T![box] => { |
@@ -182,7 +182,7 @@ fn record_field_pat(p: &mut Parser) { | |||
182 | 182 | ||
183 | let m = p.start(); | 183 | let m = p.start(); |
184 | name(p); | 184 | name(p); |
185 | p.bump(); | 185 | p.bump_any(); |
186 | pattern(p); | 186 | pattern(p); |
187 | m.complete(p, RECORD_FIELD_PAT); | 187 | m.complete(p, RECORD_FIELD_PAT); |
188 | } | 188 | } |
@@ -192,7 +192,7 @@ fn record_field_pat(p: &mut Parser) { | |||
192 | fn placeholder_pat(p: &mut Parser) -> CompletedMarker { | 192 | fn placeholder_pat(p: &mut Parser) -> CompletedMarker { |
193 | assert!(p.at(T![_])); | 193 | assert!(p.at(T![_])); |
194 | let m = p.start(); | 194 | let m = p.start(); |
195 | p.bump(); | 195 | p.bump_any(); |
196 | m.complete(p, PLACEHOLDER_PAT) | 196 | m.complete(p, PLACEHOLDER_PAT) |
197 | } | 197 | } |
198 | 198 | ||
@@ -204,7 +204,7 @@ fn placeholder_pat(p: &mut Parser) -> CompletedMarker { | |||
204 | fn ref_pat(p: &mut Parser) -> CompletedMarker { | 204 | fn ref_pat(p: &mut Parser) -> CompletedMarker { |
205 | assert!(p.at(T![&])); | 205 | assert!(p.at(T![&])); |
206 | let m = p.start(); | 206 | let m = p.start(); |
207 | p.bump(); | 207 | p.bump_any(); |
208 | p.eat(T![mut]); | 208 | p.eat(T![mut]); |
209 | pattern(p); | 209 | pattern(p); |
210 | m.complete(p, REF_PAT) | 210 | m.complete(p, REF_PAT) |
@@ -228,7 +228,7 @@ fn tuple_pat(p: &mut Parser) -> CompletedMarker { | |||
228 | fn slice_pat(p: &mut Parser) -> CompletedMarker { | 228 | fn slice_pat(p: &mut Parser) -> CompletedMarker { |
229 | assert!(p.at(T!['['])); | 229 | assert!(p.at(T!['['])); |
230 | let m = p.start(); | 230 | let m = p.start(); |
231 | p.bump(); | 231 | p.bump_any(); |
232 | pat_list(p, T![']']); | 232 | pat_list(p, T![']']); |
233 | p.expect(T![']']); | 233 | p.expect(T![']']); |
234 | m.complete(p, SLICE_PAT) | 234 | m.complete(p, SLICE_PAT) |
@@ -237,7 +237,7 @@ fn slice_pat(p: &mut Parser) -> CompletedMarker { | |||
237 | fn pat_list(p: &mut Parser, ket: SyntaxKind) { | 237 | fn pat_list(p: &mut Parser, ket: SyntaxKind) { |
238 | while !p.at(EOF) && !p.at(ket) { | 238 | while !p.at(EOF) && !p.at(ket) { |
239 | match p.current() { | 239 | match p.current() { |
240 | T![..] => p.bump(), | 240 | T![..] => p.bump_any(), |
241 | _ => { | 241 | _ => { |
242 | if !p.at_ts(PATTERN_FIRST) { | 242 | if !p.at_ts(PATTERN_FIRST) { |
243 | p.error("expected a pattern"); | 243 | p.error("expected a pattern"); |
@@ -281,7 +281,7 @@ fn bind_pat(p: &mut Parser, with_at: bool) -> CompletedMarker { | |||
281 | fn box_pat(p: &mut Parser) -> CompletedMarker { | 281 | fn box_pat(p: &mut Parser) -> CompletedMarker { |
282 | assert!(p.at(T![box])); | 282 | assert!(p.at(T![box])); |
283 | let m = p.start(); | 283 | let m = p.start(); |
284 | p.bump(); | 284 | p.bump_any(); |
285 | pattern(p); | 285 | pattern(p); |
286 | m.complete(p, BOX_PAT) | 286 | m.complete(p, BOX_PAT) |
287 | } | 287 | } |
diff --git a/crates/ra_parser/src/grammar/type_args.rs b/crates/ra_parser/src/grammar/type_args.rs index 3db08b280..e100af531 100644 --- a/crates/ra_parser/src/grammar/type_args.rs +++ b/crates/ra_parser/src/grammar/type_args.rs | |||
@@ -5,13 +5,13 @@ pub(super) fn opt_type_arg_list(p: &mut Parser, colon_colon_required: bool) { | |||
5 | match (colon_colon_required, p.nth(0), p.nth(1)) { | 5 | match (colon_colon_required, p.nth(0), p.nth(1)) { |
6 | (_, T![::], T![<]) => { | 6 | (_, T![::], T![<]) => { |
7 | m = p.start(); | 7 | m = p.start(); |
8 | p.bump(); | 8 | p.bump_any(); |
9 | p.bump(); | 9 | p.bump_any(); |
10 | } | 10 | } |
11 | (false, T![<], T![=]) => return, | 11 | (false, T![<], T![=]) => return, |
12 | (false, T![<], _) => { | 12 | (false, T![<], _) => { |
13 | m = p.start(); | 13 | m = p.start(); |
14 | p.bump(); | 14 | p.bump_any(); |
15 | } | 15 | } |
16 | _ => return, | 16 | _ => return, |
17 | }; | 17 | }; |
@@ -32,7 +32,7 @@ fn type_arg(p: &mut Parser) { | |||
32 | let m = p.start(); | 32 | let m = p.start(); |
33 | match p.current() { | 33 | match p.current() { |
34 | LIFETIME => { | 34 | LIFETIME => { |
35 | p.bump(); | 35 | p.bump_any(); |
36 | m.complete(p, LIFETIME_ARG); | 36 | m.complete(p, LIFETIME_ARG); |
37 | } | 37 | } |
38 | // test associated_type_bounds | 38 | // test associated_type_bounds |
@@ -44,7 +44,7 @@ fn type_arg(p: &mut Parser) { | |||
44 | } | 44 | } |
45 | IDENT if p.nth(1) == T![=] => { | 45 | IDENT if p.nth(1) == T![=] => { |
46 | name_ref(p); | 46 | name_ref(p); |
47 | p.bump(); | 47 | p.bump_any(); |
48 | types::type_(p); | 48 | types::type_(p); |
49 | m.complete(p, ASSOC_TYPE_ARG); | 49 | m.complete(p, ASSOC_TYPE_ARG); |
50 | } | 50 | } |
diff --git a/crates/ra_parser/src/grammar/type_params.rs b/crates/ra_parser/src/grammar/type_params.rs index cf54344c6..31d709d81 100644 --- a/crates/ra_parser/src/grammar/type_params.rs +++ b/crates/ra_parser/src/grammar/type_params.rs | |||
@@ -10,7 +10,7 @@ pub(super) fn opt_type_param_list(p: &mut Parser) { | |||
10 | fn type_param_list(p: &mut Parser) { | 10 | fn type_param_list(p: &mut Parser) { |
11 | assert!(p.at(T![<])); | 11 | assert!(p.at(T![<])); |
12 | let m = p.start(); | 12 | let m = p.start(); |
13 | p.bump(); | 13 | p.bump_any(); |
14 | 14 | ||
15 | while !p.at(EOF) && !p.at(T![>]) { | 15 | while !p.at(EOF) && !p.at(T![>]) { |
16 | let m = p.start(); | 16 | let m = p.start(); |
@@ -38,7 +38,7 @@ fn type_param_list(p: &mut Parser) { | |||
38 | 38 | ||
39 | fn lifetime_param(p: &mut Parser, m: Marker) { | 39 | fn lifetime_param(p: &mut Parser, m: Marker) { |
40 | assert!(p.at(LIFETIME)); | 40 | assert!(p.at(LIFETIME)); |
41 | p.bump(); | 41 | p.bump_any(); |
42 | if p.at(T![:]) { | 42 | if p.at(T![:]) { |
43 | lifetime_bounds(p); | 43 | lifetime_bounds(p); |
44 | } | 44 | } |
@@ -54,7 +54,7 @@ fn type_param(p: &mut Parser, m: Marker) { | |||
54 | // test type_param_default | 54 | // test type_param_default |
55 | // struct S<T = i32>; | 55 | // struct S<T = i32>; |
56 | if p.at(T![=]) { | 56 | if p.at(T![=]) { |
57 | p.bump(); | 57 | p.bump_any(); |
58 | types::type_(p) | 58 | types::type_(p) |
59 | } | 59 | } |
60 | m.complete(p, TYPE_PARAM); | 60 | m.complete(p, TYPE_PARAM); |
@@ -64,15 +64,15 @@ fn type_param(p: &mut Parser, m: Marker) { | |||
64 | // struct S<T: 'a + ?Sized + (Copy)>; | 64 | // struct S<T: 'a + ?Sized + (Copy)>; |
65 | pub(super) fn bounds(p: &mut Parser) { | 65 | pub(super) fn bounds(p: &mut Parser) { |
66 | assert!(p.at(T![:])); | 66 | assert!(p.at(T![:])); |
67 | p.bump(); | 67 | p.bump_any(); |
68 | bounds_without_colon(p); | 68 | bounds_without_colon(p); |
69 | } | 69 | } |
70 | 70 | ||
71 | fn lifetime_bounds(p: &mut Parser) { | 71 | fn lifetime_bounds(p: &mut Parser) { |
72 | assert!(p.at(T![:])); | 72 | assert!(p.at(T![:])); |
73 | p.bump(); | 73 | p.bump_any(); |
74 | while p.at(LIFETIME) { | 74 | while p.at(LIFETIME) { |
75 | p.bump(); | 75 | p.bump_any(); |
76 | if !p.eat(T![+]) { | 76 | if !p.eat(T![+]) { |
77 | break; | 77 | break; |
78 | } | 78 | } |
@@ -99,7 +99,7 @@ fn type_bound(p: &mut Parser) -> bool { | |||
99 | let has_paren = p.eat(T!['(']); | 99 | let has_paren = p.eat(T!['(']); |
100 | p.eat(T![?]); | 100 | p.eat(T![?]); |
101 | match p.current() { | 101 | match p.current() { |
102 | LIFETIME => p.bump(), | 102 | LIFETIME => p.bump_any(), |
103 | T![for] => types::for_type(p), | 103 | T![for] => types::for_type(p), |
104 | _ if paths::is_use_path_start(p) => types::path_type_(p, false), | 104 | _ if paths::is_use_path_start(p) => types::path_type_(p, false), |
105 | _ => { | 105 | _ => { |
@@ -128,7 +128,7 @@ pub(super) fn opt_where_clause(p: &mut Parser) { | |||
128 | return; | 128 | return; |
129 | } | 129 | } |
130 | let m = p.start(); | 130 | let m = p.start(); |
131 | p.bump(); | 131 | p.bump_any(); |
132 | 132 | ||
133 | while is_where_predicate(p) { | 133 | while is_where_predicate(p) { |
134 | where_predicate(p); | 134 | where_predicate(p); |
@@ -166,7 +166,7 @@ fn where_predicate(p: &mut Parser) { | |||
166 | let m = p.start(); | 166 | let m = p.start(); |
167 | match p.current() { | 167 | match p.current() { |
168 | LIFETIME => { | 168 | LIFETIME => { |
169 | p.bump(); | 169 | p.bump_any(); |
170 | if p.at(T![:]) { | 170 | if p.at(T![:]) { |
171 | bounds(p); | 171 | bounds(p); |
172 | } else { | 172 | } else { |
diff --git a/crates/ra_parser/src/grammar/types.rs b/crates/ra_parser/src/grammar/types.rs index 9e321b2a6..0eb28ef09 100644 --- a/crates/ra_parser/src/grammar/types.rs +++ b/crates/ra_parser/src/grammar/types.rs | |||
@@ -44,7 +44,7 @@ pub(super) fn ascription(p: &mut Parser) { | |||
44 | fn paren_or_tuple_type(p: &mut Parser) { | 44 | fn paren_or_tuple_type(p: &mut Parser) { |
45 | assert!(p.at(T!['('])); | 45 | assert!(p.at(T!['('])); |
46 | let m = p.start(); | 46 | let m = p.start(); |
47 | p.bump(); | 47 | p.bump_any(); |
48 | let mut n_types: u32 = 0; | 48 | let mut n_types: u32 = 0; |
49 | let mut trailing_comma: bool = false; | 49 | let mut trailing_comma: bool = false; |
50 | while !p.at(EOF) && !p.at(T![')']) { | 50 | while !p.at(EOF) && !p.at(T![')']) { |
@@ -79,20 +79,20 @@ fn paren_or_tuple_type(p: &mut Parser) { | |||
79 | fn never_type(p: &mut Parser) { | 79 | fn never_type(p: &mut Parser) { |
80 | assert!(p.at(T![!])); | 80 | assert!(p.at(T![!])); |
81 | let m = p.start(); | 81 | let m = p.start(); |
82 | p.bump(); | 82 | p.bump_any(); |
83 | m.complete(p, NEVER_TYPE); | 83 | m.complete(p, NEVER_TYPE); |
84 | } | 84 | } |
85 | 85 | ||
86 | fn pointer_type(p: &mut Parser) { | 86 | fn pointer_type(p: &mut Parser) { |
87 | assert!(p.at(T![*])); | 87 | assert!(p.at(T![*])); |
88 | let m = p.start(); | 88 | let m = p.start(); |
89 | p.bump(); | 89 | p.bump_any(); |
90 | 90 | ||
91 | match p.current() { | 91 | match p.current() { |
92 | // test pointer_type_mut | 92 | // test pointer_type_mut |
93 | // type M = *mut (); | 93 | // type M = *mut (); |
94 | // type C = *mut (); | 94 | // type C = *mut (); |
95 | T![mut] | T![const] => p.bump(), | 95 | T![mut] | T![const] => p.bump_any(), |
96 | _ => { | 96 | _ => { |
97 | // test_err pointer_type_no_mutability | 97 | // test_err pointer_type_no_mutability |
98 | // type T = *(); | 98 | // type T = *(); |
@@ -110,21 +110,21 @@ fn pointer_type(p: &mut Parser) { | |||
110 | fn array_or_slice_type(p: &mut Parser) { | 110 | fn array_or_slice_type(p: &mut Parser) { |
111 | assert!(p.at(T!['['])); | 111 | assert!(p.at(T!['['])); |
112 | let m = p.start(); | 112 | let m = p.start(); |
113 | p.bump(); | 113 | p.bump_any(); |
114 | 114 | ||
115 | type_(p); | 115 | type_(p); |
116 | let kind = match p.current() { | 116 | let kind = match p.current() { |
117 | // test slice_type | 117 | // test slice_type |
118 | // type T = [()]; | 118 | // type T = [()]; |
119 | T![']'] => { | 119 | T![']'] => { |
120 | p.bump(); | 120 | p.bump_any(); |
121 | SLICE_TYPE | 121 | SLICE_TYPE |
122 | } | 122 | } |
123 | 123 | ||
124 | // test array_type | 124 | // test array_type |
125 | // type T = [(); 92]; | 125 | // type T = [(); 92]; |
126 | T![;] => { | 126 | T![;] => { |
127 | p.bump(); | 127 | p.bump_any(); |
128 | expressions::expr(p); | 128 | expressions::expr(p); |
129 | p.expect(T![']']); | 129 | p.expect(T![']']); |
130 | ARRAY_TYPE | 130 | ARRAY_TYPE |
@@ -146,7 +146,7 @@ fn array_or_slice_type(p: &mut Parser) { | |||
146 | fn reference_type(p: &mut Parser) { | 146 | fn reference_type(p: &mut Parser) { |
147 | assert!(p.at(T![&])); | 147 | assert!(p.at(T![&])); |
148 | let m = p.start(); | 148 | let m = p.start(); |
149 | p.bump(); | 149 | p.bump_any(); |
150 | p.eat(LIFETIME); | 150 | p.eat(LIFETIME); |
151 | p.eat(T![mut]); | 151 | p.eat(T![mut]); |
152 | type_no_bounds(p); | 152 | type_no_bounds(p); |
@@ -158,7 +158,7 @@ fn reference_type(p: &mut Parser) { | |||
158 | fn placeholder_type(p: &mut Parser) { | 158 | fn placeholder_type(p: &mut Parser) { |
159 | assert!(p.at(T![_])); | 159 | assert!(p.at(T![_])); |
160 | let m = p.start(); | 160 | let m = p.start(); |
161 | p.bump(); | 161 | p.bump_any(); |
162 | m.complete(p, PLACEHOLDER_TYPE); | 162 | m.complete(p, PLACEHOLDER_TYPE); |
163 | } | 163 | } |
164 | 164 | ||
@@ -193,7 +193,7 @@ fn fn_pointer_type(p: &mut Parser) { | |||
193 | 193 | ||
194 | pub(super) fn for_binder(p: &mut Parser) { | 194 | pub(super) fn for_binder(p: &mut Parser) { |
195 | assert!(p.at(T![for])); | 195 | assert!(p.at(T![for])); |
196 | p.bump(); | 196 | p.bump_any(); |
197 | if p.at(T![<]) { | 197 | if p.at(T![<]) { |
198 | type_params::opt_type_param_list(p); | 198 | type_params::opt_type_param_list(p); |
199 | } else { | 199 | } else { |
@@ -224,7 +224,7 @@ pub(super) fn for_type(p: &mut Parser) { | |||
224 | fn impl_trait_type(p: &mut Parser) { | 224 | fn impl_trait_type(p: &mut Parser) { |
225 | assert!(p.at(T![impl])); | 225 | assert!(p.at(T![impl])); |
226 | let m = p.start(); | 226 | let m = p.start(); |
227 | p.bump(); | 227 | p.bump_any(); |
228 | type_params::bounds_without_colon(p); | 228 | type_params::bounds_without_colon(p); |
229 | m.complete(p, IMPL_TRAIT_TYPE); | 229 | m.complete(p, IMPL_TRAIT_TYPE); |
230 | } | 230 | } |
@@ -234,7 +234,7 @@ fn impl_trait_type(p: &mut Parser) { | |||
234 | fn dyn_trait_type(p: &mut Parser) { | 234 | fn dyn_trait_type(p: &mut Parser) { |
235 | assert!(p.at(T![dyn ])); | 235 | assert!(p.at(T![dyn ])); |
236 | let m = p.start(); | 236 | let m = p.start(); |
237 | p.bump(); | 237 | p.bump_any(); |
238 | type_params::bounds_without_colon(p); | 238 | type_params::bounds_without_colon(p); |
239 | m.complete(p, DYN_TRAIT_TYPE); | 239 | m.complete(p, DYN_TRAIT_TYPE); |
240 | } | 240 | } |
diff --git a/crates/ra_parser/src/parser.rs b/crates/ra_parser/src/parser.rs index 393586561..d8567e84b 100644 --- a/crates/ra_parser/src/parser.rs +++ b/crates/ra_parser/src/parser.rs | |||
@@ -148,7 +148,7 @@ impl<'t> Parser<'t> { | |||
148 | } | 148 | } |
149 | 149 | ||
150 | /// Advances the parser by one token with composite puncts handled | 150 | /// Advances the parser by one token with composite puncts handled |
151 | pub(crate) fn bump(&mut self) { | 151 | pub(crate) fn bump_any(&mut self) { |
152 | let kind = self.nth(0); | 152 | let kind = self.nth(0); |
153 | if kind == EOF { | 153 | if kind == EOF { |
154 | return; | 154 | return; |
@@ -170,6 +170,12 @@ impl<'t> Parser<'t> { | |||
170 | } | 170 | } |
171 | } | 171 | } |
172 | 172 | ||
173 | /// Advances the parser by one token, asserting that it is exactly the expected token | ||
174 | pub(crate) fn bump(&mut self, expected: SyntaxKind) { | ||
175 | debug_assert!(self.nth(0) == expected); | ||
176 | self.bump_any() | ||
177 | } | ||
178 | |||
173 | /// Advances the parser by one token, remapping its kind. | 179 | /// Advances the parser by one token, remapping its kind. |
174 | /// This is useful to create contextual keywords from | 180 | /// This is useful to create contextual keywords from |
175 | /// identifiers. For example, the lexer creates an `union` | 181 | /// identifiers. For example, the lexer creates an `union` |
@@ -205,7 +211,7 @@ impl<'t> Parser<'t> { | |||
205 | if !self.at(kind) { | 211 | if !self.at(kind) { |
206 | return false; | 212 | return false; |
207 | } | 213 | } |
208 | self.bump(); | 214 | self.bump_any(); |
209 | true | 215 | true |
210 | } | 216 | } |
211 | 217 | ||
@@ -231,7 +237,7 @@ impl<'t> Parser<'t> { | |||
231 | } else { | 237 | } else { |
232 | let m = self.start(); | 238 | let m = self.start(); |
233 | self.error(message); | 239 | self.error(message); |
234 | self.bump(); | 240 | self.bump_any(); |
235 | m.complete(self, ERROR); | 241 | m.complete(self, ERROR); |
236 | }; | 242 | }; |
237 | } | 243 | } |