aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax
diff options
context:
space:
mode:
authorDJMcNab <[email protected]>2019-01-27 14:55:03 +0000
committerDJMcNab <[email protected]>2019-01-27 14:55:03 +0000
commit73b075c5562f351b84b6c96b7852547c7b50a1ef (patch)
treea3c50faa7628d0800fbe5b98891320b8a36e5914 /crates/ra_syntax
parent964086e0d4874d7e60eb3607220e486ec4b51f86 (diff)
Correctly parse inner attributes of impl blocks
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r--crates/ra_syntax/src/grammar/items/traits.rs7
-rw-r--r--crates/ra_syntax/tests/data/parser/inline/ok/0118_impl_inner_attributes.rs5
-rw-r--r--crates/ra_syntax/tests/data/parser/inline/ok/0118_impl_inner_attributes.txt38
3 files changed, 50 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/grammar/items/traits.rs b/crates/ra_syntax/src/grammar/items/traits.rs
index 0a0621753..d5a8ccd98 100644
--- a/crates/ra_syntax/src/grammar/items/traits.rs
+++ b/crates/ra_syntax/src/grammar/items/traits.rs
@@ -78,6 +78,13 @@ pub(crate) fn impl_item_list(p: &mut Parser) {
78 assert!(p.at(L_CURLY)); 78 assert!(p.at(L_CURLY));
79 let m = p.start(); 79 let m = p.start();
80 p.bump(); 80 p.bump();
81 // test impl_inner_attributes
82 // enum F{}
83 // impl F {
84 // //! This is a doc comment
85 // #![doc("This is also a doc comment")]
86 // }
87 attributes::inner_attributes(p);
81 88
82 while !p.at(EOF) && !p.at(R_CURLY) { 89 while !p.at(EOF) && !p.at(R_CURLY) {
83 if p.at(L_CURLY) { 90 if p.at(L_CURLY) {
diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0118_impl_inner_attributes.rs b/crates/ra_syntax/tests/data/parser/inline/ok/0118_impl_inner_attributes.rs
new file mode 100644
index 000000000..4d68cceb7
--- /dev/null
+++ b/crates/ra_syntax/tests/data/parser/inline/ok/0118_impl_inner_attributes.rs
@@ -0,0 +1,5 @@
1enum F{}
2impl F {
3 //! This is a doc comment
4 #![doc("This is also a doc comment")]
5}
diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0118_impl_inner_attributes.txt b/crates/ra_syntax/tests/data/parser/inline/ok/0118_impl_inner_attributes.txt
new file mode 100644
index 000000000..3b761b7bb
--- /dev/null
+++ b/crates/ra_syntax/tests/data/parser/inline/ok/0118_impl_inner_attributes.txt
@@ -0,0 +1,38 @@
1SOURCE_FILE@[0; 94)
2 ENUM_DEF@[0; 8)
3 ENUM_KW@[0; 4)
4 WHITESPACE@[4; 5)
5 NAME@[5; 6)
6 IDENT@[5; 6) "F"
7 ENUM_VARIANT_LIST@[6; 8)
8 L_CURLY@[6; 7)
9 R_CURLY@[7; 8)
10 WHITESPACE@[8; 9)
11 IMPL_BLOCK@[9; 93)
12 IMPL_KW@[9; 13)
13 WHITESPACE@[13; 14)
14 PATH_TYPE@[14; 15)
15 PATH@[14; 15)
16 PATH_SEGMENT@[14; 15)
17 NAME_REF@[14; 15)
18 IDENT@[14; 15) "F"
19 WHITESPACE@[15; 16)
20 ITEM_LIST@[16; 93)
21 L_CURLY@[16; 17)
22 WHITESPACE@[17; 23)
23 COMMENT@[23; 48)
24 WHITESPACE@[48; 54)
25 ATTR@[54; 91)
26 POUND@[54; 55)
27 EXCL@[55; 56)
28 TOKEN_TREE@[56; 91)
29 L_BRACK@[56; 57)
30 IDENT@[57; 60) "doc"
31 TOKEN_TREE@[60; 90)
32 L_PAREN@[60; 61)
33 STRING@[61; 89)
34 R_PAREN@[89; 90)
35 R_BRACK@[90; 91)
36 WHITESPACE@[91; 92)
37 R_CURLY@[92; 93)
38 WHITESPACE@[93; 94)