1
Fork 0

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

@ -1364,9 +1364,9 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
record!(self.tables.params_in_repr[def_id] <- params_in_repr);
if adt_def.is_enum() {
let module_children = tcx.module_children_non_reexports(local_def_id);
let module_children = tcx.module_children_local(local_def_id);
record_array!(self.tables.module_children_non_reexports[def_id] <-
module_children.iter().map(|def_id| def_id.local_def_index));
module_children.iter().map(|child| child.res.def_id().index));
} else {
// For non-enum, there is only one variant, and its def_id is the adt's.
debug_assert_eq!(adt_def.variants().len(), 1);
@ -1412,12 +1412,14 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
// Encode this here because we don't do it in encode_def_ids.
record!(self.tables.expn_that_defined[def_id] <- tcx.expn_that_defined(local_def_id));
} else {
let non_reexports = tcx.module_children_non_reexports(local_def_id);
let module_children = tcx.module_children_local(local_def_id);
record_array!(self.tables.module_children_non_reexports[def_id] <-
non_reexports.iter().map(|def_id| def_id.local_def_index));
module_children.iter().filter(|child| child.reexport_chain.is_empty())
.map(|child| child.res.def_id().index));
record_defaulted_array!(self.tables.module_children_reexports[def_id] <-
tcx.module_children_reexports(local_def_id));
module_children.iter().filter(|child| !child.reexport_chain.is_empty()));
}
}
@ -1676,9 +1678,9 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
hir::ItemKind::Trait(..) => {
record!(self.tables.trait_def[def_id] <- self.tcx.trait_def(def_id));
let module_children = tcx.module_children_non_reexports(item.owner_id.def_id);
let module_children = tcx.module_children_local(item.owner_id.def_id);
record_array!(self.tables.module_children_non_reexports[def_id] <-
module_children.iter().map(|def_id| def_id.local_def_index));
module_children.iter().map(|child| child.res.def_id().index));
let associated_item_def_ids = self.tcx.associated_item_def_ids(def_id);
record_associated_item_def_ids(self, associated_item_def_ids);

View file

@ -357,10 +357,16 @@ define_tables! {
associated_types_for_impl_traits_in_associated_fn: Table<DefIndex, LazyArray<DefId>>,
opt_rpitit_info: Table<DefIndex, Option<LazyValue<ty::ImplTraitInTraitData>>>,
unused_generic_params: Table<DefIndex, UnusedGenericParams>,
// Reexported names are not associated with individual `DefId`s,
// e.g. a glob import can introduce a lot of names, all with the same `DefId`.
// That's why the encoded list needs to contain `ModChild` structures describing all the names
// individually instead of `DefId`s.
module_children_reexports: Table<DefIndex, LazyArray<ModChild>>,
- optional:
attributes: Table<DefIndex, LazyArray<ast::Attribute>>,
// For non-reexported names in a module every name is associated with a separate `DefId`,
// so we can take their names, visibilities etc from other encoded tables.
module_children_non_reexports: Table<DefIndex, LazyArray<DefIndex>>,
associated_item_or_field_def_ids: Table<DefIndex, LazyArray<DefIndex>>,
opt_def_kind: Table<DefIndex, DefKind>,