From 0b9e462ab0c6d74fd0bb34d9b9101132373e65a3 Mon Sep 17 00:00:00 2001 From: DJMcNab <36049421+DJMcNab@users.noreply.github.com> Date: Sat, 12 Jan 2019 15:42:12 +0000 Subject: Fix handling of attributes in positional field lists --- crates/ra_syntax/src/grammar/items/nominal.rs | 10 ++++++ .../data/parser/inline/ok/0115_pos_field_attrs.rs | 4 +++ .../data/parser/inline/ok/0115_pos_field_attrs.txt | 39 ++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 crates/ra_syntax/tests/data/parser/inline/ok/0115_pos_field_attrs.rs create mode 100644 crates/ra_syntax/tests/data/parser/inline/ok/0115_pos_field_attrs.txt (limited to 'crates/ra_syntax') diff --git a/crates/ra_syntax/src/grammar/items/nominal.rs b/crates/ra_syntax/src/grammar/items/nominal.rs index 495462ca7..0784fb7b1 100644 --- a/crates/ra_syntax/src/grammar/items/nominal.rs +++ b/crates/ra_syntax/src/grammar/items/nominal.rs @@ -140,6 +140,16 @@ fn pos_field_list(p: &mut Parser) { } while !p.at(R_PAREN) && !p.at(EOF) { let m = p.start(); + // test pos_field_attrs + // struct S ( + // #[serde(with = "url_serde")] + // pub Uri, + // ); + // + // enum S { + // Uri(#[serde(with = "url_serde")] Uri), + // } + attributes::outer_attributes(p); opt_visibility(p); if !p.at_ts(types::TYPE_FIRST) { p.error("expected a type"); diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0115_pos_field_attrs.rs b/crates/ra_syntax/tests/data/parser/inline/ok/0115_pos_field_attrs.rs new file mode 100644 index 000000000..635b9ac21 --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/inline/ok/0115_pos_field_attrs.rs @@ -0,0 +1,4 @@ +struct S ( + #[serde(with = "url_serde")] + pub Uri, +); diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0115_pos_field_attrs.txt b/crates/ra_syntax/tests/data/parser/inline/ok/0115_pos_field_attrs.txt new file mode 100644 index 000000000..99ec0755b --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/inline/ok/0115_pos_field_attrs.txt @@ -0,0 +1,39 @@ +SOURCE_FILE@[0; 60) + STRUCT_DEF@[0; 59) + STRUCT_KW@[0; 6) + WHITESPACE@[6; 7) + NAME@[7; 8) + IDENT@[7; 8) "S" + WHITESPACE@[8; 9) + POS_FIELD_LIST@[9; 58) + L_PAREN@[9; 10) + WHITESPACE@[10; 15) + POS_FIELD@[15; 55) + ATTR@[15; 43) + POUND@[15; 16) + TOKEN_TREE@[16; 43) + L_BRACK@[16; 17) + IDENT@[17; 22) "serde" + TOKEN_TREE@[22; 42) + L_PAREN@[22; 23) + IDENT@[23; 27) "with" + WHITESPACE@[27; 28) + EQ@[28; 29) + WHITESPACE@[29; 30) + STRING@[30; 41) + R_PAREN@[41; 42) + R_BRACK@[42; 43) + WHITESPACE@[43; 48) + VISIBILITY@[48; 51) + PUB_KW@[48; 51) + WHITESPACE@[51; 52) + PATH_TYPE@[52; 55) + PATH@[52; 55) + PATH_SEGMENT@[52; 55) + NAME_REF@[52; 55) + IDENT@[52; 55) "Uri" + COMMA@[55; 56) + WHITESPACE@[56; 57) + R_PAREN@[57; 58) + SEMI@[58; 59) + WHITESPACE@[59; 60) -- cgit v1.2.3