aboutsummaryrefslogtreecommitdiff
path: root/crates/hir
diff options
context:
space:
mode:
authorLukas Tobias Wirth <[email protected]>2021-05-23 18:33:28 +0100
committerLukas Tobias Wirth <[email protected]>2021-05-23 18:37:01 +0100
commitda74c66947ec847f2ca8e99d96cc7e36fd494c75 (patch)
tree0f9f18647a70d38fc1c02761de8f4d9f16fb3283 /crates/hir
parentf04daf693aec9f3ffbd98bd368b79646246d506b (diff)
Correctly resolve crate name in use paths when import shadows itself
Diffstat (limited to 'crates/hir')
-rw-r--r--crates/hir/src/source_analyzer.rs11
1 files changed, 10 insertions, 1 deletions
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 {
286 let ctx = body::LowerCtx::with_hygiene(db.upcast(), &hygiene); 286 let ctx = body::LowerCtx::with_hygiene(db.upcast(), &hygiene);
287 let hir_path = Path::from_src(path.clone(), &ctx)?; 287 let hir_path = Path::from_src(path.clone(), &ctx)?;
288 288
289 // Case where path is a qualifier of another path, e.g. foo::bar::Baz where we 289 // Case where path is a qualifier of another path, e.g. foo::bar::Baz where we are
290 // trying to resolve foo::bar. 290 // trying to resolve foo::bar.
291 if let Some(outer_path) = parent().and_then(ast::Path::cast) { 291 if let Some(outer_path) = parent().and_then(ast::Path::cast) {
292 if let Some(qualifier) = outer_path.qualifier() { 292 if let Some(qualifier) = outer_path.qualifier() {
@@ -295,6 +295,15 @@ impl SourceAnalyzer {
295 } 295 }
296 } 296 }
297 } 297 }
298 // Case where path is a qualifier of a use tree, e.g. foo::bar::{Baz, Qux} where we are
299 // trying to resolve foo::bar.
300 if let Some(use_tree) = parent().and_then(ast::UseTree::cast) {
301 if let Some(qualifier) = use_tree.path() {
302 if path == &qualifier && use_tree.coloncolon_token().is_some() {
303 return resolve_hir_path_qualifier(db, &self.resolver, &hir_path);
304 }
305 }
306 }
298 307
299 resolve_hir_path_(db, &self.resolver, &hir_path, prefer_value_ns) 308 resolve_hir_path_(db, &self.resolver, &hir_path, prefer_value_ns)
300 } 309 }