aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-09-09 09:45:00 +0100
committerGitHub <[email protected]>2019-09-09 09:45:00 +0100
commit734a43e95afc97773c234956a95b78caed88f2a3 (patch)
treee7fd1ed3cd7cf00f36541c33c84ce4a2ac6559e5 /crates/ra_syntax
parent1db08a54c20c244718e2378272c72ae5c6651f06 (diff)
parentf3cbdb07c56fcfab1d65488836caafc1f395a0d1 (diff)
Merge #1793
1793: Fix outer doc-comments of `macro_rules` r=matklad a=uHOOCCOOHu Document comments of `macro_rules!` is currently parsed outside the `MACRO_CALL` node, which makes `DocCommentsOwner::doc_comments()` always empty. For the input: ```rust /// Some docs macro_rules! foo { () => {}; } ``` Current parsing tree is: ``` SOURCE_FILE COMMENT // <- This should be children of MACRO_CALL WHITESPACE MACRO_CALL PATH <...omitted...> ``` It should be: ``` SOURCE_FILE MACRO_CALL COMMENT WHITESPACE PATH <...omitted...> ``` Co-authored-by: uHOOCCOOHu <[email protected]>
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r--crates/ra_syntax/src/parsing/text_tree_sink.rs4
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0053_outer_attribute_on_macro_rules.rs5
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0053_outer_attribute_on_macro_rules.txt37
3 files changed, 44 insertions, 2 deletions
diff --git a/crates/ra_syntax/src/parsing/text_tree_sink.rs b/crates/ra_syntax/src/parsing/text_tree_sink.rs
index f59c559e9..be6e51780 100644
--- a/crates/ra_syntax/src/parsing/text_tree_sink.rs
+++ b/crates/ra_syntax/src/parsing/text_tree_sink.rs
@@ -144,8 +144,8 @@ fn n_attached_trivias<'a>(
144 trivias: impl Iterator<Item = (SyntaxKind, &'a str)>, 144 trivias: impl Iterator<Item = (SyntaxKind, &'a str)>,
145) -> usize { 145) -> usize {
146 match kind { 146 match kind {
147 CONST_DEF | TYPE_ALIAS_DEF | STRUCT_DEF | ENUM_DEF | ENUM_VARIANT | FN_DEF | TRAIT_DEF 147 MACRO_CALL | CONST_DEF | TYPE_ALIAS_DEF | STRUCT_DEF | ENUM_DEF | ENUM_VARIANT | FN_DEF
148 | MODULE | RECORD_FIELD_DEF => { 148 | TRAIT_DEF | MODULE | RECORD_FIELD_DEF => {
149 let mut res = 0; 149 let mut res = 0;
150 for (i, (kind, text)) in trivias.enumerate() { 150 for (i, (kind, text)) in trivias.enumerate() {
151 match kind { 151 match kind {
diff --git a/crates/ra_syntax/test_data/parser/ok/0053_outer_attribute_on_macro_rules.rs b/crates/ra_syntax/test_data/parser/ok/0053_outer_attribute_on_macro_rules.rs
new file mode 100644
index 000000000..b59c23c56
--- /dev/null
+++ b/crates/ra_syntax/test_data/parser/ok/0053_outer_attribute_on_macro_rules.rs
@@ -0,0 +1,5 @@
1/// Some docs
2#[macro_export]
3macro_rules! foo {
4 () => {};
5}
diff --git a/crates/ra_syntax/test_data/parser/ok/0053_outer_attribute_on_macro_rules.txt b/crates/ra_syntax/test_data/parser/ok/0053_outer_attribute_on_macro_rules.txt
new file mode 100644
index 000000000..f77221f76
--- /dev/null
+++ b/crates/ra_syntax/test_data/parser/ok/0053_outer_attribute_on_macro_rules.txt
@@ -0,0 +1,37 @@
1SOURCE_FILE@[0; 65)
2 MACRO_CALL@[0; 64)
3 COMMENT@[0; 13) "/// Some docs"
4 WHITESPACE@[13; 14) "\n"
5 ATTR@[14; 29)
6 POUND@[14; 15) "#"
7 TOKEN_TREE@[15; 29)
8 L_BRACK@[15; 16) "["
9 IDENT@[16; 28) "macro_export"
10 R_BRACK@[28; 29) "]"
11 WHITESPACE@[29; 30) "\n"
12 PATH@[30; 41)
13 PATH_SEGMENT@[30; 41)
14 NAME_REF@[30; 41)
15 IDENT@[30; 41) "macro_rules"
16 EXCL@[41; 42) "!"
17 WHITESPACE@[42; 43) " "
18 NAME@[43; 46)
19 IDENT@[43; 46) "foo"
20 WHITESPACE@[46; 47) " "
21 TOKEN_TREE@[47; 64)
22 L_CURLY@[47; 48) "{"
23 WHITESPACE@[48; 53) "\n "
24 TOKEN_TREE@[53; 55)
25 L_PAREN@[53; 54) "("
26 R_PAREN@[54; 55) ")"
27 WHITESPACE@[55; 56) " "
28 EQ@[56; 57) "="
29 R_ANGLE@[57; 58) ">"
30 WHITESPACE@[58; 59) " "
31 TOKEN_TREE@[59; 61)
32 L_CURLY@[59; 60) "{"
33 R_CURLY@[60; 61) "}"
34 SEMI@[61; 62) ";"
35 WHITESPACE@[62; 63) "\n"
36 R_CURLY@[63; 64) "}"
37 WHITESPACE@[64; 65) "\n"