diff options
Diffstat (limited to 'crates')
3 files changed, 54 insertions, 1 deletions
diff --git a/crates/ra_parser/src/grammar/expressions.rs b/crates/ra_parser/src/grammar/expressions.rs index d1f27dadf..a0d5a99cb 100644 --- a/crates/ra_parser/src/grammar/expressions.rs +++ b/crates/ra_parser/src/grammar/expressions.rs | |||
@@ -452,8 +452,13 @@ pub(crate) fn named_field_list(p: &mut Parser) { | |||
452 | p.bump(); | 452 | p.bump(); |
453 | while !p.at(EOF) && !p.at(R_CURLY) { | 453 | while !p.at(EOF) && !p.at(R_CURLY) { |
454 | match p.current() { | 454 | match p.current() { |
455 | IDENT => { | 455 | // test struct_literal_field_with_attr |
456 | // fn main() { | ||
457 | // S { #[cfg(test)] field: 1 } | ||
458 | // } | ||
459 | IDENT | POUND => { | ||
456 | let m = p.start(); | 460 | let m = p.start(); |
461 | attributes::outer_attributes(p); | ||
457 | name_ref(p); | 462 | name_ref(p); |
458 | if p.eat(COLON) { | 463 | if p.eat(COLON) { |
459 | expr(p); | 464 | expr(p); |
diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0125_struct_literal_field_with_attr.rs b/crates/ra_syntax/tests/data/parser/inline/ok/0125_struct_literal_field_with_attr.rs new file mode 100644 index 000000000..a6c7760c7 --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/inline/ok/0125_struct_literal_field_with_attr.rs | |||
@@ -0,0 +1,3 @@ | |||
1 | fn main() { | ||
2 | S { #[cfg(test)] field: 1 } | ||
3 | } | ||
diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0125_struct_literal_field_with_attr.txt b/crates/ra_syntax/tests/data/parser/inline/ok/0125_struct_literal_field_with_attr.txt new file mode 100644 index 000000000..34c80500a --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/inline/ok/0125_struct_literal_field_with_attr.txt | |||
@@ -0,0 +1,45 @@ | |||
1 | SOURCE_FILE@[0; 46) | ||
2 | FN_DEF@[0; 45) | ||
3 | FN_KW@[0; 2) | ||
4 | WHITESPACE@[2; 3) | ||
5 | NAME@[3; 7) | ||
6 | IDENT@[3; 7) "main" | ||
7 | PARAM_LIST@[7; 9) | ||
8 | L_PAREN@[7; 8) | ||
9 | R_PAREN@[8; 9) | ||
10 | WHITESPACE@[9; 10) | ||
11 | BLOCK@[10; 45) | ||
12 | L_CURLY@[10; 11) | ||
13 | WHITESPACE@[11; 16) | ||
14 | STRUCT_LIT@[16; 43) | ||
15 | PATH@[16; 17) | ||
16 | PATH_SEGMENT@[16; 17) | ||
17 | NAME_REF@[16; 17) | ||
18 | IDENT@[16; 17) "S" | ||
19 | WHITESPACE@[17; 18) | ||
20 | NAMED_FIELD_LIST@[18; 43) | ||
21 | L_CURLY@[18; 19) | ||
22 | WHITESPACE@[19; 20) | ||
23 | NAMED_FIELD@[20; 41) | ||
24 | ATTR@[20; 32) | ||
25 | POUND@[20; 21) | ||
26 | TOKEN_TREE@[21; 32) | ||
27 | L_BRACK@[21; 22) | ||
28 | IDENT@[22; 25) "cfg" | ||
29 | TOKEN_TREE@[25; 31) | ||
30 | L_PAREN@[25; 26) | ||
31 | IDENT@[26; 30) "test" | ||
32 | R_PAREN@[30; 31) | ||
33 | R_BRACK@[31; 32) | ||
34 | WHITESPACE@[32; 33) | ||
35 | NAME_REF@[33; 38) | ||
36 | IDENT@[33; 38) "field" | ||
37 | COLON@[38; 39) | ||
38 | WHITESPACE@[39; 40) | ||
39 | LITERAL@[40; 41) | ||
40 | INT_NUMBER@[40; 41) "1" | ||
41 | WHITESPACE@[41; 42) | ||
42 | R_CURLY@[42; 43) | ||
43 | WHITESPACE@[43; 44) | ||
44 | R_CURLY@[44; 45) | ||
45 | WHITESPACE@[45; 46) | ||