aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_db/src
diff options
context:
space:
mode:
authorKirill Bulatov <[email protected]>2021-02-28 07:57:54 +0000
committerKirill Bulatov <[email protected]>2021-03-08 21:59:20 +0000
commit9482353fa8e1e88cb720a029b9bb6304819c7399 (patch)
tree6438293e05f70af6106b4e421ec0afe7d586632c /crates/ide_db/src
parentd386481fac65e988fa4d13c1bc8d4ddb2bc490c6 (diff)
Properly handle turbofishes in qualifiers
Diffstat (limited to 'crates/ide_db/src')
-rw-r--r--crates/ide_db/src/helpers/import_assets.rs12
1 files changed, 7 insertions, 5 deletions
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 {