Obtain ModuleId's DefMap through a method

This commit is contained in:
Jonas Schievink
2021-01-22 16:31:40 +01:00
parent a5322e3d5b
commit ce29730bc7
14 changed files with 43 additions and 32 deletions

View File

@@ -50,7 +50,10 @@ pub mod import_map;
#[cfg(test)]
mod test_db;
use std::hash::{Hash, Hasher};
use std::{
hash::{Hash, Hasher},
sync::Arc,
};
use base_db::{impl_intern_key, salsa, CrateId};
use hir_expand::{
@@ -58,6 +61,7 @@ use hir_expand::{
MacroCallId, MacroCallKind, MacroDefId, MacroDefKind,
};
use la_arena::Idx;
use nameres::DefMap;
use syntax::ast;
use crate::builtin_type::BuiltinType;
@@ -73,6 +77,12 @@ pub struct ModuleId {
pub local_id: LocalModuleId,
}
impl ModuleId {
pub fn def_map(&self, db: &dyn db::DefDatabase) -> Arc<DefMap> {
db.crate_def_map(self.krate)
}
}
/// An ID of a module, **local** to a specific crate
pub type LocalModuleId = Idx<nameres::ModuleData>;