]> git.lizzy.rs Git - rust.git/commitdiff
Add make::glob_use_tree function to create star-only UseTree
authorLukas Wirth <lukastw97@gmail.com>
Wed, 16 Sep 2020 18:33:08 +0000 (20:33 +0200)
committerLukas Wirth <lukastw97@gmail.com>
Wed, 16 Sep 2020 18:33:08 +0000 (20:33 +0200)
crates/assists/src/utils/insert_use.rs
crates/syntax/src/ast/make.rs

index 4972085d693adda04d65333d1bec7928570c23a9..97ac6b8322bc2c1513533748e5fbf19bb7db7541 100644 (file)
@@ -233,15 +233,7 @@ fn recursive_merge(
                             None,
                             false,
                         );
-                        use_trees.insert(
-                            idx,
-                            make::use_tree(
-                                make::path_unqualified(make::path_segment_self()),
-                                None,
-                                None,
-                                true,
-                            ),
-                        );
+                        use_trees.insert(idx, make::glob_use_tree());
                         continue;
                     }
                 }
@@ -806,14 +798,14 @@ fn merge_mod_into_glob() {
         check_full(
             "token::TokenKind",
             r"use token::TokenKind::*;",
-            r"use token::TokenKind::{self::*, self};",
+            r"use token::TokenKind::{*, self};",
         )
         // FIXME: have it emit `use token::TokenKind::{self, *}`?
     }
 
     #[test]
     fn merge_self_glob() {
-        check_full("self", r"use self::*;", r"use self::{self::*, self};")
+        check_full("self", r"use self::*;", r"use self::{*, self};")
         // FIXME: have it emit `use {self, *}`?
     }
 
index 25e8a359d9e2324774c7465aec81945fe3b99625..6868feed9976ad6e66bbe3435599fff5baa183c6 100644 (file)
@@ -38,6 +38,10 @@ pub fn path_from_text(text: &str) -> ast::Path {
     ast_from_text(text)
 }
 
+pub fn glob_use_tree() -> ast::UseTree {
+    ast_from_text("use *;")
+}
+
 pub fn use_tree(
     path: ast::Path,
     use_tree_list: Option<ast::UseTreeList>,