diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-04-11 18:37:02 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-04-11 18:37:02 +0100 |
commit | 1a1c09ed3e3a34c0a8750f98ece9ad85595395d2 (patch) | |
tree | 44136a4ce738d388bb9b0ce9f5569cf68465cbe2 /crates/ra_parser/src/grammar | |
parent | 11d400b63b07d3cffbe8d1363b802a2d52f5d786 (diff) | |
parent | 0aece75cdd40daa4d48484103cfcd36ba13ba076 (diff) |
Merge #3951
3951: Simplify records grammar r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_parser/src/grammar')
-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![,]); |