mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-25 12:33:33 +00:00
allow field attrs
This commit is contained in:
parent
a5515d9d6f
commit
eda52cbc34
3 changed files with 54 additions and 3 deletions
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
struct S {
|
||||
#[serde(with = "url_serde")]
|
||||
pub uri: Uri,
|
||||
}
|
|
@ -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)
|
Loading…
Reference in a new issue