File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
crates/assists/src/handlers Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -135,8 +135,12 @@ fn insert_import(
135135 variant_hir_name : & Name ,
136136) -> Option < ( ) > {
137137 let db = ctx. db ( ) ;
138- let mod_path = module. find_use_path ( db, enum_module_def. clone ( ) ) ;
139- if let Some ( mut mod_path) = mod_path. filter ( |path| path. len ( ) > 1 ) {
138+ let mod_path = module. find_use_path_prefixed (
139+ db,
140+ enum_module_def. clone ( ) ,
141+ ctx. config . insert_use . prefix_kind ,
142+ ) ;
143+ if let Some ( mut mod_path) = mod_path. filter ( |path| !path. is_ident ( ) ) {
140144 mod_path. segments . pop ( ) ;
141145 mod_path. segments . push ( variant_hir_name. clone ( ) ) ;
142146 let scope = ImportScope :: find_insert_use_container ( scope_node, ctx) ?;
@@ -323,7 +327,7 @@ fn another_fn() {
323327 r#"use my_mod::my_other_mod::MyField;
324328
325329mod my_mod {
326- use my_other_mod::MyField;
330+ use self:: my_other_mod::MyField;
327331
328332 fn another_fn() {
329333 let m = my_other_mod::MyEnum::MyField(MyField(1, 1));
@@ -402,7 +406,7 @@ enum E {
402406mod foo;
403407
404408//- /foo.rs
405- use crate::E ;
409+ use crate::{E, V} ;
406410fn f() {
407411 let e = E::V(V(9, 2));
408412}
@@ -437,7 +441,7 @@ enum E {
437441mod foo;
438442
439443//- /foo.rs
440- use crate::E ;
444+ use crate::{E, V} ;
441445fn f() {
442446 let e = E::V(V { i: 9, j: 2 });
443447}
You can’t perform that action at this time.
0 commit comments