From 5914f86d473f34e0fa78dc150024b07bd26a2db9 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Tue, 2 Feb 2021 18:02:12 +0100 Subject: Fix resolution of `crate` paths from within blocks They resolve to the crate root, not the DefMap's root module (which can be a block) --- crates/hir_def/src/nameres/path_resolution.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/hir_def/src/nameres/path_resolution.rs') diff --git a/crates/hir_def/src/nameres/path_resolution.rs b/crates/hir_def/src/nameres/path_resolution.rs index 2d1477160..ecf75c777 100644 --- a/crates/hir_def/src/nameres/path_resolution.rs +++ b/crates/hir_def/src/nameres/path_resolution.rs @@ -152,7 +152,7 @@ impl DefMap { PathKind::DollarCrate(krate) => { if krate == self.krate { mark::hit!(macro_dollar_crate_self); - PerNs::types(self.module_id(self.root).into(), Visibility::Public) + PerNs::types(self.crate_root().into(), Visibility::Public) } else { let def_map = db.crate_def_map(krate); let module = def_map.module_id(def_map.root); @@ -160,7 +160,7 @@ impl DefMap { PerNs::types(module.into(), Visibility::Public) } } - PathKind::Crate => PerNs::types(self.module_id(self.root).into(), Visibility::Public), + PathKind::Crate => PerNs::types(self.crate_root().into(), Visibility::Public), // plain import or absolute path in 2015: crate-relative with // fallback to extern prelude (with the simplification in // rust-lang/rust#57745) -- cgit v1.2.3