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

@ -31,6 +31,7 @@ impl SourceToDefCtx<'_, '_> {
pub(super) fn file_to_def(&mut self, file: FileId) -> Option<ModuleId> {
let _p = profile::span("SourceBinder::to_module_def");
let (krate, local_id) = self.db.relevant_crates(file).iter().find_map(|&crate_id| {
// FIXME: inner items
let crate_def_map = self.db.crate_def_map(crate_id);
let local_id = crate_def_map.modules_for_file(file).next()?;
Some((crate_id, local_id))
@ -60,7 +61,7 @@ impl SourceToDefCtx<'_, '_> {
}?;
let child_name = src.value.name()?.as_name();
let def_map = self.db.crate_def_map(parent_module.krate);
let def_map = parent_module.def_map(self.db.upcast());
let child_id = *def_map[parent_module.local_id].children.get(&child_name)?;
Some(ModuleId { krate: parent_module.krate, local_id: child_id })
}