resolve: One more attempt to simplify module_children

This commit is contained in:
Vadim Petrochenkov 2023-04-27 18:34:43 +03:00
parent 98c33e47a4
commit ef77dd232d
10 changed files with 45 additions and 53 deletions

View file

@ -152,8 +152,9 @@ pub(crate) fn try_inline_glob(
// reexported by the glob, e.g. because they are shadowed by something else.
let reexports = cx
.tcx
.module_children_reexports(current_mod)
.module_children_local(current_mod)
.iter()
.filter(|child| !child.reexport_chain.is_empty())
.filter_map(|child| child.res.opt_def_id())
.collect();
let mut items = build_module_items(cx, did, visited, inlined_names, Some(&reexports));

View file

@ -2089,9 +2089,9 @@ pub(crate) fn reexport_chain<'tcx>(
import_def_id: LocalDefId,
target_def_id: LocalDefId,
) -> &'tcx [Reexport] {
for child in tcx.module_children_reexports(tcx.local_parent(import_def_id)) {
for child in tcx.module_children_local(tcx.local_parent(import_def_id)) {
if child.res.opt_def_id() == Some(target_def_id.to_def_id())
&& child.reexport_chain[0].id() == Some(import_def_id.to_def_id())
&& child.reexport_chain.first().and_then(|r| r.id()) == Some(import_def_id.to_def_id())
{
return &child.reexport_chain;
}

View file

@ -136,14 +136,15 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
// is declared but also a reexport of itself producing two exports of the same
// macro in the same module.
let mut inserted = FxHashSet::default();
for export in self.cx.tcx.module_children_reexports(CRATE_DEF_ID) {
if let Res::Def(DefKind::Macro(_), def_id) = export.res &&
for child in self.cx.tcx.module_children_local(CRATE_DEF_ID) {
if !child.reexport_chain.is_empty() &&
let Res::Def(DefKind::Macro(_), def_id) = child.res &&
let Some(local_def_id) = def_id.as_local() &&
self.cx.tcx.has_attr(def_id, sym::macro_export) &&
inserted.insert(def_id)
{
let item = self.cx.tcx.hir().expect_item(local_def_id);
top_level_module.items.insert((local_def_id, Some(item.ident.name)), (item, None, None));
let item = self.cx.tcx.hir().expect_item(local_def_id);
top_level_module.items.insert((local_def_id, Some(item.ident.name)), (item, None, None));
}
}