Merge #7466
7466: Fix legacy macro resolution in block expressions r=jonas-schievink a=jonas-schievink bors r+ Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
This commit is contained in:
commit
671757a5de
@ -289,6 +289,17 @@ pub(crate) fn resolve_path(
|
|||||||
(res.resolved_def, res.segment_index)
|
(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
|
// FIXME: this can use some more human-readable format (ideally, an IR
|
||||||
// even), as this should be a great debugging aid.
|
// even), as this should be a great debugging aid.
|
||||||
pub fn dump(&self) -> String {
|
pub fn dump(&self) -> String {
|
||||||
|
@ -1443,7 +1443,10 @@ fn collect_macro_call(&mut self, mac: &MacroCall) {
|
|||||||
if let Some(macro_call_id) =
|
if let Some(macro_call_id) =
|
||||||
ast_id.as_call_id(self.def_collector.db, self.def_collector.def_map.krate, |path| {
|
ast_id.as_call_id(self.def_collector.db, self.def_collector.def_map.krate, |path| {
|
||||||
path.as_ident().and_then(|name| {
|
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))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user