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/lib.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/crates/hir_def/src/lib.rs b/crates/hir_def/src/lib.rs
index 2f9261a7f..c8dbb2aeb 100644
--- a/crates/hir_def/src/lib.rs
+++ b/crates/hir_def/src/lib.rs
@@ -73,14 +73,22 @@ use stdx::impl_from;
73 73
74#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 74#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
75pub struct ModuleId { 75pub struct ModuleId {
76 pub krate: CrateId, 76 krate: CrateId,
77 pub local_id: LocalModuleId, 77 pub local_id: LocalModuleId,
78} 78}
79 79
80impl ModuleId { 80impl ModuleId {
81 pub fn top_level(krate: CrateId, local_id: LocalModuleId) -> Self {
82 Self { krate, local_id }
83 }
84
81 pub fn def_map(&self, db: &dyn db::DefDatabase) -> Arc<DefMap> { 85 pub fn def_map(&self, db: &dyn db::DefDatabase) -> Arc<DefMap> {
82 db.crate_def_map(self.krate) 86 db.crate_def_map(self.krate)
83 } 87 }
88
89 pub fn krate(&self) -> CrateId {
90 self.krate
91 }
84} 92}
85 93
86/// An ID of a module, **local** to a specific crate 94/// An ID of a module, **local** to a specific crate