diff options
Diffstat (limited to 'crates/ra_parser/src/grammar/expressions.rs')
-rw-r--r-- | crates/ra_parser/src/grammar/expressions.rs | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/crates/ra_parser/src/grammar/expressions.rs b/crates/ra_parser/src/grammar/expressions.rs index a1bd53063..cb30b25a8 100644 --- a/crates/ra_parser/src/grammar/expressions.rs +++ b/crates/ra_parser/src/grammar/expressions.rs | |||
@@ -619,26 +619,39 @@ pub(crate) fn record_field_list(p: &mut Parser) { | |||
619 | let m = p.start(); | 619 | let m = p.start(); |
620 | p.bump(T!['{']); | 620 | p.bump(T!['{']); |
621 | while !p.at(EOF) && !p.at(T!['}']) { | 621 | while !p.at(EOF) && !p.at(T!['}']) { |
622 | let m = p.start(); | ||
623 | // test record_literal_field_with_attr | ||
624 | // fn main() { | ||
625 | // S { #[cfg(test)] field: 1 } | ||
626 | // } | ||
627 | attributes::outer_attributes(p); | ||
628 | |||
622 | match p.current() { | 629 | match p.current() { |
623 | // test record_literal_field_with_attr | 630 | IDENT | INT_NUMBER => { |
624 | // fn main() { | 631 | // test_err record_literal_before_ellipsis_recovery |
625 | // S { #[cfg(test)] field: 1 } | 632 | // fn main() { |
626 | // } | 633 | // S { field ..S::default() } |
627 | IDENT | INT_NUMBER | T![#] => { | 634 | // } |
628 | let m = p.start(); | 635 | if p.nth_at(1, T![:]) || p.nth_at(1, T![..]) { |
629 | attributes::outer_attributes(p); | 636 | name_ref_or_index(p); |
630 | name_ref_or_index(p); | 637 | p.expect(T![:]); |
631 | if p.eat(T![:]) { | ||
632 | expr(p); | ||
633 | } | 638 | } |
639 | expr(p); | ||
634 | m.complete(p, RECORD_FIELD); | 640 | m.complete(p, RECORD_FIELD); |
635 | } | 641 | } |
636 | T![.] if p.at(T![..]) => { | 642 | T![.] if p.at(T![..]) => { |
643 | m.abandon(p); | ||
637 | p.bump(T![..]); | 644 | p.bump(T![..]); |
638 | expr(p); | 645 | expr(p); |
639 | } | 646 | } |
640 | T!['{'] => error_block(p, "expected a field"), | 647 | T!['{'] => { |
641 | _ => p.err_and_bump("expected identifier"), | 648 | error_block(p, "expected a field"); |
649 | m.abandon(p); | ||
650 | } | ||
651 | _ => { | ||
652 | p.err_and_bump("expected identifier"); | ||
653 | m.abandon(p); | ||
654 | } | ||
642 | } | 655 | } |
643 | if !p.at(T!['}']) { | 656 | if !p.at(T!['}']) { |
644 | p.expect(T![,]); | 657 | p.expect(T![,]); |