aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/libsyntax2/src/grammar/items/structs.rs12
-rw-r--r--crates/libsyntax2/tests/data/parser/inline/0103_field_attrs.rs4
-rw-r--r--crates/libsyntax2/tests/data/parser/inline/0103_field_attrs.txt41
3 files changed, 54 insertions, 3 deletions
diff --git a/crates/libsyntax2/src/grammar/items/structs.rs b/crates/libsyntax2/src/grammar/items/structs.rs
index 80e77edd3..41bd2a4e0 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) {
84 p.expect(R_CURLY); 84 p.expect(R_CURLY);
85 85
86 fn named_field(p: &mut Parser) { 86 fn named_field(p: &mut Parser) {
87 let field = p.start(); 87 let m = p.start();
88 // test field_attrs
89 // struct S {
90 // #[serde(with = "url_serde")]
91 // pub uri: Uri,
92 // }
93 attributes::outer_attributes(p);
88 visibility(p); 94 visibility(p);
89 if p.at(IDENT) { 95 if p.at(IDENT) {
90 name(p); 96 name(p);
91 p.expect(COLON); 97 p.expect(COLON);
92 types::type_(p); 98 types::type_(p);
93 field.complete(p, NAMED_FIELD); 99 m.complete(p, NAMED_FIELD);
94 } else { 100 } else {
95 field.abandon(p); 101 m.abandon(p);
96 p.err_and_bump("expected field declaration"); 102 p.err_and_bump("expected field declaration");
97 } 103 }
98 } 104 }
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 000000000..4744d8ac0
--- /dev/null
+++ b/crates/libsyntax2/tests/data/parser/inline/0103_field_attrs.rs
@@ -0,0 +1,4 @@
1struct S {
2 #[serde(with = "url_serde")]
3 pub uri: Uri,
4}
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 000000000..f4e2d9716
--- /dev/null
+++ b/crates/libsyntax2/tests/data/parser/inline/0103_field_attrs.txt
@@ -0,0 +1,41 @@
1FILE@[0; 64)
2 STRUCT_DEF@[0; 63)
3 STRUCT_KW@[0; 6)
4 WHITESPACE@[6; 7)
5 NAME@[7; 8)
6 IDENT@[7; 8) "S"
7 WHITESPACE@[8; 9)
8 L_CURLY@[9; 10)
9 WHITESPACE@[10; 15)
10 NAMED_FIELD@[15; 60)
11 ATTR@[15; 43)
12 POUND@[15; 16)
13 TOKEN_TREE@[16; 43)
14 L_BRACK@[16; 17)
15 IDENT@[17; 22) "serde"
16 TOKEN_TREE@[22; 42)
17 L_PAREN@[22; 23)
18 IDENT@[23; 27) "with"
19 WHITESPACE@[27; 28)
20 EQ@[28; 29)
21 WHITESPACE@[29; 30)
22 STRING@[30; 41)
23 R_PAREN@[41; 42)
24 R_BRACK@[42; 43)
25 WHITESPACE@[43; 48)
26 VISIBILITY@[48; 51)
27 PUB_KW@[48; 51)
28 WHITESPACE@[51; 52)
29 NAME@[52; 55)
30 IDENT@[52; 55) "uri"
31 COLON@[55; 56)
32 WHITESPACE@[56; 57)
33 PATH_TYPE@[57; 60)
34 PATH@[57; 60)
35 PATH_SEGMENT@[57; 60)
36 NAME_REF@[57; 60)
37 IDENT@[57; 60) "Uri"
38 COMMA@[60; 61)
39 WHITESPACE@[61; 62)
40 R_CURLY@[62; 63)
41 WHITESPACE@[63; 64)