diff options
Diffstat (limited to 'crates/hir_def/src')
-rw-r--r-- | crates/hir_def/src/nameres.rs | 11 | ||||
-rw-r--r-- | crates/hir_def/src/nameres/collector.rs | 5 |
2 files changed, 15 insertions, 1 deletions
diff --git a/crates/hir_def/src/nameres.rs b/crates/hir_def/src/nameres.rs index 199771e9a..005b36e02 100644 --- a/crates/hir_def/src/nameres.rs +++ b/crates/hir_def/src/nameres.rs | |||
@@ -289,6 +289,17 @@ impl DefMap { | |||
289 | (res.resolved_def, res.segment_index) | 289 | (res.resolved_def, res.segment_index) |
290 | } | 290 | } |
291 | 291 | ||
292 | /// Iterates over the containing `DefMap`s, if `self` is a `DefMap` corresponding to a block | ||
293 | /// expression. | ||
294 | fn ancestor_maps( | ||
295 | &self, | ||
296 | local_mod: LocalModuleId, | ||
297 | ) -> impl Iterator<Item = (&DefMap, LocalModuleId)> { | ||
298 | std::iter::successors(Some((self, local_mod)), |(map, _)| { | ||
299 | map.block.as_ref().map(|block| (&*block.parent, block.parent_module)) | ||
300 | }) | ||
301 | } | ||
302 | |||
292 | // FIXME: this can use some more human-readable format (ideally, an IR | 303 | // FIXME: this can use some more human-readable format (ideally, an IR |
293 | // even), as this should be a great debugging aid. | 304 | // even), as this should be a great debugging aid. |
294 | pub fn dump(&self) -> String { | 305 | pub fn dump(&self) -> String { |
diff --git a/crates/hir_def/src/nameres/collector.rs b/crates/hir_def/src/nameres/collector.rs index 393170b32..761b29c86 100644 --- a/crates/hir_def/src/nameres/collector.rs +++ b/crates/hir_def/src/nameres/collector.rs | |||
@@ -1443,7 +1443,10 @@ impl ModCollector<'_, '_> { | |||
1443 | if let Some(macro_call_id) = | 1443 | if let Some(macro_call_id) = |
1444 | ast_id.as_call_id(self.def_collector.db, self.def_collector.def_map.krate, |path| { | 1444 | ast_id.as_call_id(self.def_collector.db, self.def_collector.def_map.krate, |path| { |
1445 | path.as_ident().and_then(|name| { | 1445 | path.as_ident().and_then(|name| { |
1446 | self.def_collector.def_map[self.module_id].scope.get_legacy_macro(&name) | 1446 | self.def_collector |
1447 | .def_map | ||
1448 | .ancestor_maps(self.module_id) | ||
1449 | .find_map(|(map, module)| map[module].scope.get_legacy_macro(&name)) | ||
1447 | }) | 1450 | }) |
1448 | }) | 1451 | }) |
1449 | { | 1452 | { |