]> git.lizzy.rs Git - rust.git/commitdiff
Add a FIXME for non-unified inner attributes
authorKirill Bulatov <mail4score@gmail.com>
Wed, 11 Nov 2020 12:04:31 +0000 (14:04 +0200)
committerKirill Bulatov <mail4score@gmail.com>
Thu, 12 Nov 2020 11:46:02 +0000 (13:46 +0200)
crates/assists/src/utils/insert_use.rs

index c4de83f773a9538232795f77129ed521a955612e..5d726370af678b58d31a53b40e3388af78f4c7f0 100644 (file)
@@ -72,6 +72,11 @@ fn insert_pos_after_inner_elements(&self) -> (InsertPosition<SyntaxElement>, Add
                     if is_inner_node(maybe_inner_node.clone()) {
                         last_inner_element = Some(NodeOrToken::Node(maybe_inner_node))
                     } else {
+                        // FIXME: https://doc.rust-lang.org/reference/comments.html#doc-comments
+                        // states that inner comments (`//!` and `/*!`) are equal to inner attribute `#![doc="..."]`
+                        // yet RA treats them differently now: inner attributes never belong to child nodes,
+                        // but inner comments can, ergo this check.
+                        // We need to align this and treat both cases the same way.
                         if let Some(maybe_inner_token) = maybe_inner_node.first_token() {
                             if is_inner_token(maybe_inner_token.clone()) {
                                 last_inner_element = Some(NodeOrToken::Token(maybe_inner_token))
@@ -877,11 +882,11 @@ fn inserts_after_multiline_inner_comments() {
             "foo::bar::Baz",
             r#"/*! Multiline inner comments do not allow any code before them. */
 
-/*! RA considers this inner comment belonging to the function, yet we still cannot place the code before it. */
+/*! Still an inner comment, cannot place any code before. */
 fn main() {}"#,
             r#"/*! Multiline inner comments do not allow any code before them. */
 
-/*! RA considers this inner comment belonging to the function, yet we still cannot place the code before it. */
+/*! Still an inner comment, cannot place any code before. */
 
 use foo::bar::Baz;
 fn main() {}"#,