diff options
author | Aleksey Kladov <[email protected]> | 2020-01-17 10:15:07 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-01-17 10:15:07 +0000 |
commit | 90b8a31b83b1aafc3fb555ba4307527f9258f46d (patch) | |
tree | b4f5acac622f1514b83dc4dc11321a0ca484308d | |
parent | ea2b27d8b978fbe2307991ff28d6030eabf5b82c (diff) | |
parent | f077d5c303ecc4f38471b37be985bb0c5ab2f68c (diff) |
Merge pull request #2813 from jyn514/arg_attributes
Allow attributes before function arguments
3 files changed, 45 insertions, 0 deletions
diff --git a/crates/ra_parser/src/grammar/expressions.rs b/crates/ra_parser/src/grammar/expressions.rs index d733499d1..a31a7a08d 100644 --- a/crates/ra_parser/src/grammar/expressions.rs +++ b/crates/ra_parser/src/grammar/expressions.rs | |||
@@ -540,6 +540,11 @@ fn arg_list(p: &mut Parser) { | |||
540 | let m = p.start(); | 540 | let m = p.start(); |
541 | p.bump(T!['(']); | 541 | p.bump(T!['(']); |
542 | while !p.at(T![')']) && !p.at(EOF) { | 542 | while !p.at(T![')']) && !p.at(EOF) { |
543 | // test arg_with_attr | ||
544 | // fn main() { | ||
545 | // foo(#[attr] 92) | ||
546 | // } | ||
547 | attributes::outer_attributes(p); | ||
543 | if !p.at_ts(EXPR_FIRST) { | 548 | if !p.at_ts(EXPR_FIRST) { |
544 | p.error("expected expression"); | 549 | p.error("expected expression"); |
545 | break; | 550 | break; |
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0152_arg_with_attr.rs b/crates/ra_syntax/test_data/parser/inline/ok/0152_arg_with_attr.rs new file mode 100644 index 000000000..5daf1d7b0 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/inline/ok/0152_arg_with_attr.rs | |||
@@ -0,0 +1,3 @@ | |||
1 | fn main() { | ||
2 | foo(#[attr] 92) | ||
3 | } | ||
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0152_arg_with_attr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0152_arg_with_attr.txt new file mode 100644 index 000000000..6b80ca8d0 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/inline/ok/0152_arg_with_attr.txt | |||
@@ -0,0 +1,37 @@ | |||
1 | SOURCE_FILE@[0; 34) | ||
2 | FN_DEF@[0; 33) | ||
3 | FN_KW@[0; 2) "fn" | ||
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_EXPR@[10; 33) | ||
12 | BLOCK@[10; 33) | ||
13 | L_CURLY@[10; 11) "{" | ||
14 | WHITESPACE@[11; 16) "\n " | ||
15 | CALL_EXPR@[16; 31) | ||
16 | PATH_EXPR@[16; 19) | ||
17 | PATH@[16; 19) | ||
18 | PATH_SEGMENT@[16; 19) | ||
19 | NAME_REF@[16; 19) | ||
20 | IDENT@[16; 19) "foo" | ||
21 | ARG_LIST@[19; 31) | ||
22 | L_PAREN@[19; 20) "(" | ||
23 | ATTR@[20; 27) | ||
24 | POUND@[20; 21) "#" | ||
25 | L_BRACK@[21; 22) "[" | ||
26 | PATH@[22; 26) | ||
27 | PATH_SEGMENT@[22; 26) | ||
28 | NAME_REF@[22; 26) | ||
29 | IDENT@[22; 26) "attr" | ||
30 | R_BRACK@[26; 27) "]" | ||
31 | WHITESPACE@[27; 28) " " | ||
32 | LITERAL@[28; 30) | ||
33 | INT_NUMBER@[28; 30) "92" | ||
34 | R_PAREN@[30; 31) ")" | ||
35 | WHITESPACE@[31; 32) "\n" | ||
36 | R_CURLY@[32; 33) "}" | ||
37 | WHITESPACE@[33; 34) "\n" | ||