(res.resolved_def, res.segment_index)
}
+ /// Iterates over the containing `DefMap`s, if `self` is a `DefMap` corresponding to a block
+ /// expression.
+ fn ancestor_maps(
+ &self,
+ local_mod: LocalModuleId,
+ ) -> impl Iterator<Item = (&DefMap, LocalModuleId)> {
+ std::iter::successors(Some((self, local_mod)), |(map, _)| {
+ map.block.as_ref().map(|block| (&*block.parent, block.parent_module))
+ })
+ }
+
// FIXME: this can use some more human-readable format (ideally, an IR
// even), as this should be a great debugging aid.
pub fn dump(&self) -> String {
if let Some(macro_call_id) =
ast_id.as_call_id(self.def_collector.db, self.def_collector.def_map.krate, |path| {
path.as_ident().and_then(|name| {
- self.def_collector.def_map[self.module_id].scope.get_legacy_macro(&name)
+ self.def_collector
+ .def_map
+ .ancestor_maps(self.module_id)
+ .find_map(|(map, module)| map[module].scope.get_legacy_macro(&name))
})
})
{