diff --git a/crates/libsyntax2/src/grammar/items/structs.rs b/crates/libsyntax2/src/grammar/items/structs.rs index 80e77edd354..41bd2a4e0a6 100644 --- a/crates/libsyntax2/src/grammar/items/structs.rs +++ b/crates/libsyntax2/src/grammar/items/structs.rs @@ -84,15 +84,21 @@ fn named_fields(p: &mut Parser) { p.expect(R_CURLY); fn named_field(p: &mut Parser) { - let field = p.start(); + let m = p.start(); + // test field_attrs + // struct S { + // #[serde(with = "url_serde")] + // pub uri: Uri, + // } + attributes::outer_attributes(p); visibility(p); if p.at(IDENT) { name(p); p.expect(COLON); types::type_(p); - field.complete(p, NAMED_FIELD); + m.complete(p, NAMED_FIELD); } else { - field.abandon(p); + m.abandon(p); p.err_and_bump("expected field declaration"); } } diff --git a/crates/libsyntax2/tests/data/parser/inline/0103_field_attrs.rs b/crates/libsyntax2/tests/data/parser/inline/0103_field_attrs.rs new file mode 100644 index 00000000000..4744d8ac065 --- /dev/null +++ b/crates/libsyntax2/tests/data/parser/inline/0103_field_attrs.rs @@ -0,0 +1,4 @@ +struct S { + #[serde(with = "url_serde")] + pub uri: Uri, +} diff --git a/crates/libsyntax2/tests/data/parser/inline/0103_field_attrs.txt b/crates/libsyntax2/tests/data/parser/inline/0103_field_attrs.txt new file mode 100644 index 00000000000..f4e2d97163a --- /dev/null +++ b/crates/libsyntax2/tests/data/parser/inline/0103_field_attrs.txt @@ -0,0 +1,41 @@ +FILE@[0; 64) + STRUCT_DEF@[0; 63) + STRUCT_KW@[0; 6) + WHITESPACE@[6; 7) + NAME@[7; 8) + IDENT@[7; 8) "S" + WHITESPACE@[8; 9) + L_CURLY@[9; 10) + WHITESPACE@[10; 15) + NAMED_FIELD@[15; 60) + 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) + NAME@[52; 55) + IDENT@[52; 55) "uri" + COLON@[55; 56) + WHITESPACE@[56; 57) + PATH_TYPE@[57; 60) + PATH@[57; 60) + PATH_SEGMENT@[57; 60) + NAME_REF@[57; 60) + IDENT@[57; 60) "Uri" + COMMA@[60; 61) + WHITESPACE@[61; 62) + R_CURLY@[62; 63) + WHITESPACE@[63; 64)