From 645a1b5d739e7101fc63cea7950d26addd8e7be2 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 22 Jan 2018 02:21:53 +0300 Subject: [PATCH] Remove high-order bits from tuple struct --- src/parser/event_parser/grammar/items.rs | 15 +++++++----- .../parser/ok/0017_attr_trailing_comma.rs | 2 ++ .../parser/ok/0017_attr_trailing_comma.txt | 23 +++++++++++++++++++ 3 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 tests/data/parser/ok/0017_attr_trailing_comma.rs create mode 100644 tests/data/parser/ok/0017_attr_trailing_comma.txt diff --git a/src/parser/event_parser/grammar/items.rs b/src/parser/event_parser/grammar/items.rs index 12b6d06c73..d341dce383 100644 --- a/src/parser/event_parser/grammar/items.rs +++ b/src/parser/event_parser/grammar/items.rs @@ -127,18 +127,21 @@ fn pos_fields(p: &mut Parser) { if !p.expect(L_PAREN) { return; } - comma_list(p, R_PAREN, |p| { - pos_field(p); - true - }); - p.expect(R_PAREN); + loop { + if p.at(R_PAREN) || p.at(EOF) { + break; + } - fn pos_field(p: &mut Parser) { let pos_field = p.start(); visibility(p); types::type_ref(p); pos_field.complete(p, POS_FIELD); + + if !p.at(R_PAREN) { + p.expect(COMMA); + } } + p.expect(R_PAREN); } fn generic_parameters(_: &mut Parser) {} diff --git a/tests/data/parser/ok/0017_attr_trailing_comma.rs b/tests/data/parser/ok/0017_attr_trailing_comma.rs new file mode 100644 index 0000000000..fe0a7bb97e --- /dev/null +++ b/tests/data/parser/ok/0017_attr_trailing_comma.rs @@ -0,0 +1,2 @@ +#[foo(a,)] +fn foo() {} diff --git a/tests/data/parser/ok/0017_attr_trailing_comma.txt b/tests/data/parser/ok/0017_attr_trailing_comma.txt new file mode 100644 index 0000000000..1b99d7ffdf --- /dev/null +++ b/tests/data/parser/ok/0017_attr_trailing_comma.txt @@ -0,0 +1,23 @@ +FILE@[0; 23) + FN_ITEM@[0; 23) + ATTR@[0; 11) + POUND@[0; 1) + L_BRACK@[1; 2) + META_ITEM@[2; 9) + IDENT@[2; 5) + L_PAREN@[5; 6) + META_ITEM@[6; 7) + IDENT@[6; 7) + COMMA@[7; 8) + R_PAREN@[8; 9) + R_BRACK@[9; 10) + WHITESPACE@[10; 11) + FN_KW@[11; 13) + WHITESPACE@[13; 14) + IDENT@[14; 17) + L_PAREN@[17; 18) + R_PAREN@[18; 19) + WHITESPACE@[19; 20) + L_CURLY@[20; 21) + R_CURLY@[21; 22) + WHITESPACE@[22; 23)