aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-01-22 17:11:48 +0000
committerGitHub <[email protected]>2021-01-22 17:11:48 +0000
commitf301da3c3d1c73dd9d438cb0736e23430287dba7 (patch)
tree586329f5641c520ef61d626736e492e33b227e25 /crates/hir_def
parentb982db88bed5e94913460dce7cd2b728ba925475 (diff)
parent3de8f57c51192fa8e57713a3580c2bcc6907a194 (diff)
Merge #7399
7399: Make `ModuleId`'s `krate` field private and audit uses r=jonas-schievink a=jonas-schievink bors r+ Co-authored-by: Jonas Schievink <[email protected]>
Diffstat (limited to 'crates/hir_def')
-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