From 73b075c5562f351b84b6c96b7852547c7b50a1ef Mon Sep 17 00:00:00 2001 From: DJMcNab <36049421+DJMcNab@users.noreply.github.com> Date: Sun, 27 Jan 2019 14:55:03 +0000 Subject: Correctly parse inner attributes of impl blocks --- crates/ra_syntax/src/grammar/items/traits.rs | 7 ++++ .../parser/inline/ok/0118_impl_inner_attributes.rs | 5 +++ .../inline/ok/0118_impl_inner_attributes.txt | 38 ++++++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 crates/ra_syntax/tests/data/parser/inline/ok/0118_impl_inner_attributes.rs create mode 100644 crates/ra_syntax/tests/data/parser/inline/ok/0118_impl_inner_attributes.txt (limited to 'crates') 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) { assert!(p.at(L_CURLY)); let m = p.start(); p.bump(); + // test impl_inner_attributes + // enum F{} + // impl F { + // //! This is a doc comment + // #![doc("This is also a doc comment")] + // } + attributes::inner_attributes(p); while !p.at(EOF) && !p.at(R_CURLY) { 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 @@ +enum F{} +impl F { + //! This is a doc comment + #![doc("This is also a doc comment")] +} 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 @@ +SOURCE_FILE@[0; 94) + ENUM_DEF@[0; 8) + ENUM_KW@[0; 4) + WHITESPACE@[4; 5) + NAME@[5; 6) + IDENT@[5; 6) "F" + ENUM_VARIANT_LIST@[6; 8) + L_CURLY@[6; 7) + R_CURLY@[7; 8) + WHITESPACE@[8; 9) + IMPL_BLOCK@[9; 93) + IMPL_KW@[9; 13) + WHITESPACE@[13; 14) + PATH_TYPE@[14; 15) + PATH@[14; 15) + PATH_SEGMENT@[14; 15) + NAME_REF@[14; 15) + IDENT@[14; 15) "F" + WHITESPACE@[15; 16) + ITEM_LIST@[16; 93) + L_CURLY@[16; 17) + WHITESPACE@[17; 23) + COMMENT@[23; 48) + WHITESPACE@[48; 54) + ATTR@[54; 91) + POUND@[54; 55) + EXCL@[55; 56) + TOKEN_TREE@[56; 91) + L_BRACK@[56; 57) + IDENT@[57; 60) "doc" + TOKEN_TREE@[60; 90) + L_PAREN@[60; 61) + STRING@[61; 89) + R_PAREN@[89; 90) + R_BRACK@[90; 91) + WHITESPACE@[91; 92) + R_CURLY@[92; 93) + WHITESPACE@[93; 94) -- cgit v1.2.3