aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/hir_def/src/path.rs4
-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_completion/src/completions/flyimport.rs2
-rw-r--r--crates/ide_db/src/helpers/import_assets.rs12
5 files changed, 14 insertions, 8 deletions
diff --git a/crates/hir_def/src/path.rs b/crates/hir_def/src/path.rs
index 0e60dc2b6..1dc085199 100644
--- a/crates/hir_def/src/path.rs
+++ b/crates/hir_def/src/path.rs
@@ -44,6 +44,10 @@ pub enum ImportAlias {
44} 44}
45 45
46impl ModPath { 46impl ModPath {
47 pub fn from_src_unhygienic(path: ast::Path) -> Option<ModPath> {
48 lower::lower_path(path, &Hygiene::new_unhygienic()).map(|it| it.mod_path)
49 }
50
47 pub fn from_src(path: ast::Path, hygiene: &Hygiene) -> Option<ModPath> { 51 pub fn from_src(path: ast::Path, hygiene: &Hygiene) -> Option<ModPath> {
48 lower::lower_path(path, hygiene).map(|it| it.mod_path) 52 lower::lower_path(path, hygiene).map(|it| it.mod_path)
49 } 53 }
diff --git a/crates/ide_assists/src/handlers/auto_import.rs b/crates/ide_assists/src/handlers/auto_import.rs
index 7188724be..e9993a7cc 100644
--- a/crates/ide_assists/src/handlers/auto_import.rs
+++ b/crates/ide_assists/src/handlers/auto_import.rs
@@ -242,7 +242,7 @@ mod tests {
242 } 242 }
243 ", 243 ",
244 r" 244 r"
245 use PubMod3::PubStruct; 245 use PubMod1::PubStruct;
246 246
247 PubStruct 247 PubStruct
248 248
diff --git a/crates/ide_assists/src/handlers/qualify_path.rs b/crates/ide_assists/src/handlers/qualify_path.rs
index a40cdd80e..261178448 100644
--- a/crates/ide_assists/src/handlers/qualify_path.rs
+++ b/crates/ide_assists/src/handlers/qualify_path.rs
@@ -313,7 +313,7 @@ mod tests {
313 } 313 }
314 ", 314 ",
315 r" 315 r"
316 PubMod3::PubStruct 316 PubMod1::PubStruct
317 317
318 pub mod PubMod1 { 318 pub mod PubMod1 {
319 pub struct PubStruct; 319 pub struct PubStruct;
diff --git a/crates/ide_completion/src/completions/flyimport.rs b/crates/ide_completion/src/completions/flyimport.rs
index e33fc4b78..af49fdd26 100644
--- a/crates/ide_completion/src/completions/flyimport.rs
+++ b/crates/ide_completion/src/completions/flyimport.rs
@@ -669,8 +669,8 @@ fn main() {
669} 669}
670"#, 670"#,
671 expect![[r#" 671 expect![[r#"
672 ct SPECIAL_CONST (dep::test_mod::TestTrait) DEPRECATED
673 fn weird_function() (dep::test_mod::TestTrait) -> () DEPRECATED 672 fn weird_function() (dep::test_mod::TestTrait) -> () DEPRECATED
673 ct SPECIAL_CONST (dep::test_mod::TestTrait) DEPRECATED
674 "#]], 674 "#]],
675 ); 675 );
676 } 676 }
diff --git a/crates/ide_db/src/helpers/import_assets.rs b/crates/ide_db/src/helpers/import_assets.rs
index 3d79f9771..2e7a183d1 100644
--- a/crates/ide_db/src/helpers/import_assets.rs
+++ b/crates/ide_db/src/helpers/import_assets.rs
@@ -43,7 +43,7 @@ pub struct PathImportCandidate {
43#[derive(Debug)] 43#[derive(Debug)]
44pub enum Qualifier { 44pub enum Qualifier {
45 Absent, 45 Absent,
46 FirstSegmentUnresolved(ast::PathSegment, ast::Path), 46 FirstSegmentUnresolved(ast::NameRef, ModPath),
47} 47}
48 48
49#[derive(Debug)] 49#[derive(Debug)]
@@ -297,8 +297,7 @@ fn path_applicable_imports(
297 Qualifier::FirstSegmentUnresolved(first_segment, qualifier) => (first_segment, qualifier), 297 Qualifier::FirstSegmentUnresolved(first_segment, qualifier) => (first_segment, qualifier),
298 }; 298 };
299 299
300 // TODO kb need to remove turbofish from the qualifier, maybe use the segments instead? 300 // TODO kb zz.syntax().ast_node() <- two options are now proposed despite the trait being imported
301 // TODO kb sorting is changed now, return back?
302 let unresolved_qualifier_string = unresolved_qualifier.to_string(); 301 let unresolved_qualifier_string = unresolved_qualifier.to_string();
303 let unresolved_first_segment_string = unresolved_first_segment.to_string(); 302 let unresolved_first_segment_string = unresolved_first_segment.to_string();
304 303
@@ -525,12 +524,15 @@ fn path_import_candidate(
525 Some(qualifier) => match sema.resolve_path(&qualifier) { 524 Some(qualifier) => match sema.resolve_path(&qualifier) {
526 None => { 525 None => {
527 let qualifier_start = 526 let qualifier_start =
528 qualifier.syntax().descendants().find_map(ast::PathSegment::cast)?; 527 qualifier.syntax().descendants().find_map(ast::NameRef::cast)?;
529 let qualifier_start_path = 528 let qualifier_start_path =
530 qualifier_start.syntax().ancestors().find_map(ast::Path::cast)?; 529 qualifier_start.syntax().ancestors().find_map(ast::Path::cast)?;
531 if sema.resolve_path(&qualifier_start_path).is_none() { 530 if sema.resolve_path(&qualifier_start_path).is_none() {
532 ImportCandidate::Path(PathImportCandidate { 531 ImportCandidate::Path(PathImportCandidate {
533 qualifier: Qualifier::FirstSegmentUnresolved(qualifier_start, qualifier), 532 qualifier: Qualifier::FirstSegmentUnresolved(
533 qualifier_start,
534 ModPath::from_src_unhygienic(qualifier)?,
535 ),
534 name, 536 name,
535 }) 537 })
536 } else { 538 } else {