aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_def/src')
-rw-r--r--crates/hir_def/src/nameres.rs5
-rw-r--r--crates/hir_def/src/nameres/path_resolution.rs4
2 files changed, 7 insertions, 2 deletions
diff --git a/crates/hir_def/src/nameres.rs b/crates/hir_def/src/nameres.rs
index 5efc2fe47..0a15fc470 100644
--- a/crates/hir_def/src/nameres.rs
+++ b/crates/hir_def/src/nameres.rs
@@ -275,6 +275,11 @@ impl DefMap {
275 ModuleId { krate: self.krate, local_id, block } 275 ModuleId { krate: self.krate, local_id, block }
276 } 276 }
277 277
278 pub(crate) fn crate_root(&self) -> ModuleId {
279 let (root_map, _) = self.ancestor_maps(self.root).last().unwrap();
280 root_map.module_id(root_map.root)
281 }
282
278 pub(crate) fn resolve_path( 283 pub(crate) fn resolve_path(
279 &self, 284 &self,
280 db: &dyn DefDatabase, 285 db: &dyn DefDatabase,
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 {
152 PathKind::DollarCrate(krate) => { 152 PathKind::DollarCrate(krate) => {
153 if krate == self.krate { 153 if krate == self.krate {
154 mark::hit!(macro_dollar_crate_self); 154 mark::hit!(macro_dollar_crate_self);
155 PerNs::types(self.module_id(self.root).into(), Visibility::Public) 155 PerNs::types(self.crate_root().into(), Visibility::Public)
156 } else { 156 } else {
157 let def_map = db.crate_def_map(krate); 157 let def_map = db.crate_def_map(krate);
158 let module = def_map.module_id(def_map.root); 158 let module = def_map.module_id(def_map.root);
@@ -160,7 +160,7 @@ impl DefMap {
160 PerNs::types(module.into(), Visibility::Public) 160 PerNs::types(module.into(), Visibility::Public)
161 } 161 }
162 } 162 }
163 PathKind::Crate => PerNs::types(self.module_id(self.root).into(), Visibility::Public), 163 PathKind::Crate => PerNs::types(self.crate_root().into(), Visibility::Public),
164 // plain import or absolute path in 2015: crate-relative with 164 // plain import or absolute path in 2015: crate-relative with
165 // fallback to extern prelude (with the simplification in 165 // fallback to extern prelude (with the simplification in
166 // rust-lang/rust#57745) 166 // rust-lang/rust#57745)