diff options
| author | Ryo Yoshida <low.ryoshida@gmail.com> | 2023-06-27 15:22:05 +0900 |
|---|---|---|
| committer | Ryo Yoshida <low.ryoshida@gmail.com> | 2023-06-27 15:29:08 +0900 |
| commit | a02846343f031d4fe97b6b7d68e7fbd20ad8c783 (patch) | |
| tree | 622be1a52cd74ed4bff52f4b964f51717d0c8406 /crates/hir-def/src/nameres.rs | |
| parent | 8769cd24bcb742d33b2deeb010342ab8e41eb103 (diff) | |
| download | rust-a02846343f031d4fe97b6b7d68e7fbd20ad8c783.tar.gz rust-a02846343f031d4fe97b6b7d68e7fbd20ad8c783.zip | |
Fix `self` and `super` path resolution in block modules
Diffstat (limited to 'crates/hir-def/src/nameres.rs')
| -rw-r--r-- | crates/hir-def/src/nameres.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/crates/hir-def/src/nameres.rs b/crates/hir-def/src/nameres.rs index e7a4355d258..86818ce26dd 100644 --- a/crates/hir-def/src/nameres.rs +++ b/crates/hir-def/src/nameres.rs @@ -196,6 +196,10 @@ impl BlockRelativeModuleId { fn into_module(self, krate: CrateId) -> ModuleId { ModuleId { krate, block: self.block, local_id: self.local_id } } + + fn is_block_module(self) -> bool { + self.block.is_some() && self.local_id == DefMap::ROOT + } } impl std::ops::Index<LocalModuleId> for DefMap { @@ -278,7 +282,9 @@ pub struct ModuleData { pub origin: ModuleOrigin, /// Declared visibility of this module. pub visibility: Visibility, - /// Always [`None`] for block modules + /// Parent module in the same `DefMap`. + /// + /// [`None`] for block modules because they are always its `DefMap`'s root. pub parent: Option<LocalModuleId>, pub children: FxHashMap<Name, LocalModuleId>, pub scope: ItemScope, |
