diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-02-05 18:26:51 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-02-05 18:26:51 +0000 |
commit | 4e86aee60b7b42263012461d527755a17fd1226f (patch) | |
tree | 8c2dfa181f07eee0be7b3b2684d83ed0df82bb3b /crates/hir_def/src/nameres | |
parent | 80ab753d7e0bf59b81df317d6ddda43cb919ec83 (diff) | |
parent | c312ab51d0d0bcee9514e08e6fafea26d061ea67 (diff) |
Merge #7575
7575: Fix resolution of `self` module within blocks r=jonas-schievink a=jonas-schievink
bors r+
Co-authored-by: Jonas Schievink <[email protected]>
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 |