From 9482353fa8e1e88cb720a029b9bb6304819c7399 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Sun, 28 Feb 2021 09:57:54 +0200 Subject: Properly handle turbofishes in qualifiers --- crates/ide_db/src/helpers/import_assets.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'crates/ide_db/src') 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 { #[derive(Debug)] pub enum Qualifier { Absent, - FirstSegmentUnresolved(ast::PathSegment, ast::Path), + FirstSegmentUnresolved(ast::NameRef, ModPath), } #[derive(Debug)] @@ -297,8 +297,7 @@ fn path_applicable_imports( Qualifier::FirstSegmentUnresolved(first_segment, qualifier) => (first_segment, qualifier), }; - // TODO kb need to remove turbofish from the qualifier, maybe use the segments instead? - // TODO kb sorting is changed now, return back? + // TODO kb zz.syntax().ast_node() <- two options are now proposed despite the trait being imported let unresolved_qualifier_string = unresolved_qualifier.to_string(); let unresolved_first_segment_string = unresolved_first_segment.to_string(); @@ -525,12 +524,15 @@ fn path_import_candidate( Some(qualifier) => match sema.resolve_path(&qualifier) { None => { let qualifier_start = - qualifier.syntax().descendants().find_map(ast::PathSegment::cast)?; + qualifier.syntax().descendants().find_map(ast::NameRef::cast)?; let qualifier_start_path = qualifier_start.syntax().ancestors().find_map(ast::Path::cast)?; if sema.resolve_path(&qualifier_start_path).is_none() { ImportCandidate::Path(PathImportCandidate { - qualifier: Qualifier::FirstSegmentUnresolved(qualifier_start, qualifier), + qualifier: Qualifier::FirstSegmentUnresolved( + qualifier_start, + ModPath::from_src_unhygienic(qualifier)?, + ), name, }) } else { -- cgit v1.2.3