aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ide_assists/src/handlers/auto_import.rs2
-rw-r--r--crates/ide_assists/src/handlers/qualify_path.rs2
-rw-r--r--crates/ide_db/src/helpers/import_assets.rs11
3 files changed, 7 insertions, 8 deletions
diff --git a/crates/ide_assists/src/handlers/auto_import.rs b/crates/ide_assists/src/handlers/auto_import.rs
index f3c969eee..eb8d35e95 100644
--- a/crates/ide_assists/src/handlers/auto_import.rs
+++ b/crates/ide_assists/src/handlers/auto_import.rs
@@ -245,7 +245,7 @@ mod tests {
245 } 245 }
246 ", 246 ",
247 r" 247 r"
248 use PubMod1::PubStruct; 248 use PubMod3::PubStruct;
249 249
250 PubStruct 250 PubStruct
251 251
diff --git a/crates/ide_assists/src/handlers/qualify_path.rs b/crates/ide_assists/src/handlers/qualify_path.rs
index 407ba47be..b36dd3823 100644
--- a/crates/ide_assists/src/handlers/qualify_path.rs
+++ b/crates/ide_assists/src/handlers/qualify_path.rs
@@ -317,7 +317,7 @@ mod tests {
317 } 317 }
318 ", 318 ",
319 r" 319 r"
320 PubMod1::PubStruct 320 PubMod3::PubStruct
321 321
322 pub mod PubMod1 { 322 pub mod PubMod1 {
323 pub struct PubStruct; 323 pub struct PubStruct;
diff --git a/crates/ide_db/src/helpers/import_assets.rs b/crates/ide_db/src/helpers/import_assets.rs
index b3e90717a..b78d1969d 100644
--- a/crates/ide_db/src/helpers/import_assets.rs
+++ b/crates/ide_db/src/helpers/import_assets.rs
@@ -3,6 +3,7 @@ use hir::{
3 AsAssocItem, AssocItem, AssocItemContainer, Crate, ItemInNs, MacroDef, ModPath, Module, 3 AsAssocItem, AssocItem, AssocItemContainer, Crate, ItemInNs, MacroDef, ModPath, Module,
4 ModuleDef, Name, PathResolution, PrefixKind, ScopeDef, Semantics, SemanticsScope, Type, 4 ModuleDef, Name, PathResolution, PrefixKind, ScopeDef, Semantics, SemanticsScope, Type,
5}; 5};
6use itertools::Itertools;
6use rustc_hash::FxHashSet; 7use rustc_hash::FxHashSet;
7use syntax::{ast, AstNode}; 8use syntax::{ast, AstNode};
8 9
@@ -164,16 +165,13 @@ impl<'a> ImportAssets<'a> {
164 &self, 165 &self,
165 sema: &Semantics<RootDatabase>, 166 sema: &Semantics<RootDatabase>,
166 prefix_kind: PrefixKind, 167 prefix_kind: PrefixKind,
167 ) -> FxHashSet<LocatedImport> { 168 ) -> Vec<LocatedImport> {
168 let _p = profile::span("import_assets::search_for_imports"); 169 let _p = profile::span("import_assets::search_for_imports");
169 self.search_for(sema, Some(prefix_kind)) 170 self.search_for(sema, Some(prefix_kind))
170 } 171 }
171 172
172 /// This may return non-absolute paths if a part of the returned path is already imported into scope. 173 /// This may return non-absolute paths if a part of the returned path is already imported into scope.
173 pub fn search_for_relative_paths( 174 pub fn search_for_relative_paths(&self, sema: &Semantics<RootDatabase>) -> Vec<LocatedImport> {
174 &self,
175 sema: &Semantics<RootDatabase>,
176 ) -> FxHashSet<LocatedImport> {
177 let _p = profile::span("import_assets::search_for_relative_paths"); 175 let _p = profile::span("import_assets::search_for_relative_paths");
178 self.search_for(sema, None) 176 self.search_for(sema, None)
179 } 177 }
@@ -182,7 +180,7 @@ impl<'a> ImportAssets<'a> {
182 &self, 180 &self,
183 sema: &Semantics<RootDatabase>, 181 sema: &Semantics<RootDatabase>,
184 prefixed: Option<PrefixKind>, 182 prefixed: Option<PrefixKind>,
185 ) -> FxHashSet<LocatedImport> { 183 ) -> Vec<LocatedImport> {
186 let items_with_candidate_name = match self.name_to_import() { 184 let items_with_candidate_name = match self.name_to_import() {
187 NameToImport::Exact(exact_name) => items_locator::with_for_exact_name( 185 NameToImport::Exact(exact_name) => items_locator::with_for_exact_name(
188 sema, 186 sema,
@@ -216,6 +214,7 @@ impl<'a> ImportAssets<'a> {
216 .into_iter() 214 .into_iter()
217 .filter(|import| import.import_path.len() > 1) 215 .filter(|import| import.import_path.len() > 1)
218 .filter(|import| !scope_definitions.contains(&ScopeDef::from(import.item_to_import))) 216 .filter(|import| !scope_definitions.contains(&ScopeDef::from(import.item_to_import)))
217 .sorted_by_key(|import| import.import_path.clone())
219 .collect() 218 .collect()
220 } 219 }
221 220