diff options
author | Jonas Schievink <[email protected]> | 2021-02-05 18:24:03 +0000 |
---|---|---|
committer | Jonas Schievink <[email protected]> | 2021-02-05 18:24:03 +0000 |
commit | 997bd97b77e0cacf7eb8e466071e416492cc24b3 (patch) | |
tree | 903383bc4aec9ff57974289a1dce5bcbc7c37fb1 /crates/hir_def/src/nameres | |
parent | 80ab753d7e0bf59b81df317d6ddda43cb919ec83 (diff) |
Fix resolution of `self` module within blocks
Diffstat (limited to 'crates/hir_def/src/nameres')
-rw-r--r-- | crates/hir_def/src/nameres/path_resolution.rs | 10 |
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 |