aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src/nameres
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_def/src/nameres')
-rw-r--r--crates/hir_def/src/nameres/path_resolution.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/crates/hir_def/src/nameres/path_resolution.rs b/crates/hir_def/src/nameres/path_resolution.rs
index 036e389b0..fdcdc23ae 100644
--- a/crates/hir_def/src/nameres/path_resolution.rs
+++ b/crates/hir_def/src/nameres/path_resolution.rs
@@ -227,7 +227,15 @@ impl DefMap {
227 } 227 }
228 } 228 }
229 229
230 PerNs::types(self.module_id(module).into(), Visibility::Public) 230 // Resolve `self` to the containing crate-rooted module if we're a block
231 self.with_ancestor_maps(db, module, &mut |def_map, module| {
232 if def_map.block.is_some() {
233 None // keep ascending
234 } else {
235 Some(PerNs::types(def_map.module_id(module).into(), Visibility::Public))
236 }
237 })
238 .expect("block DefMap not rooted in crate DefMap")
231 } 239 }
232 PathKind::Abs => { 240 PathKind::Abs => {
233 // 2018-style absolute path -- only extern prelude 241 // 2018-style absolute path -- only extern prelude