From 3de8f57c51192fa8e57713a3580c2bcc6907a194 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Fri, 22 Jan 2021 18:09:55 +0100 Subject: Make `ModuleId`'s `krate` field private --- crates/hir_def/src/lib.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'crates/hir_def/src') 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; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct ModuleId { - pub krate: CrateId, + krate: CrateId, pub local_id: LocalModuleId, } impl ModuleId { + pub fn top_level(krate: CrateId, local_id: LocalModuleId) -> Self { + Self { krate, local_id } + } + pub fn def_map(&self, db: &dyn db::DefDatabase) -> Arc { db.crate_def_map(self.krate) } + + pub fn krate(&self) -> CrateId { + self.krate + } } /// An ID of a module, **local** to a specific crate -- cgit v1.2.3