From da74c66947ec847f2ca8e99d96cc7e36fd494c75 Mon Sep 17 00:00:00 2001 From: Lukas Tobias Wirth Date: Sun, 23 May 2021 19:33:28 +0200 Subject: Correctly resolve crate name in use paths when import shadows itself --- crates/hir/src/source_analyzer.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'crates/hir/src/source_analyzer.rs') diff --git a/crates/hir/src/source_analyzer.rs b/crates/hir/src/source_analyzer.rs index b5c65808e..20753314d 100644 --- a/crates/hir/src/source_analyzer.rs +++ b/crates/hir/src/source_analyzer.rs @@ -286,7 +286,7 @@ impl SourceAnalyzer { let ctx = body::LowerCtx::with_hygiene(db.upcast(), &hygiene); let hir_path = Path::from_src(path.clone(), &ctx)?; - // Case where path is a qualifier of another path, e.g. foo::bar::Baz where we + // Case where path is a qualifier of another path, e.g. foo::bar::Baz where we are // trying to resolve foo::bar. if let Some(outer_path) = parent().and_then(ast::Path::cast) { if let Some(qualifier) = outer_path.qualifier() { @@ -295,6 +295,15 @@ impl SourceAnalyzer { } } } + // Case where path is a qualifier of a use tree, e.g. foo::bar::{Baz, Qux} where we are + // trying to resolve foo::bar. + if let Some(use_tree) = parent().and_then(ast::UseTree::cast) { + if let Some(qualifier) = use_tree.path() { + if path == &qualifier && use_tree.coloncolon_token().is_some() { + return resolve_hir_path_qualifier(db, &self.resolver, &hir_path); + } + } + } resolve_hir_path_(db, &self.resolver, &hir_path, prefer_value_ns) } -- cgit v1.2.3