1
Fork 0

Create a module-reexports table.

This commit is contained in:
Camille GILLOT 2022-07-03 17:54:15 +02:00
parent d330dc8c11
commit affb12210d
3 changed files with 11 additions and 18 deletions

View file

@ -1086,14 +1086,10 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
} }
} }
match self.kind(id) { if let Some(exports) = self.root.tables.module_reexports.get(self, id) {
EntryKind::Mod(exports) => { for exp in exports.decode((self, sess)) {
for exp in exports.decode((self, sess)) { callback(exp);
callback(exp);
}
} }
EntryKind::Enum | EntryKind::Trait => {}
_ => bug!("`for_each_module_child` is called on a non-module: {:?}", self.def_kind(id)),
} }
} }
@ -1106,10 +1102,8 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
} }
fn module_expansion(self, id: DefIndex, sess: &Session) -> ExpnId { fn module_expansion(self, id: DefIndex, sess: &Session) -> ExpnId {
match self.kind(id) { match self.def_kind(id) {
EntryKind::Mod(_) | EntryKind::Enum | EntryKind::Trait => { DefKind::Mod | DefKind::Enum | DefKind::Trait => self.get_expn_that_defined(id, sess),
self.get_expn_that_defined(id, sess)
}
_ => panic!("Expected module, found {:?}", self.local_def_id(id)), _ => panic!("Expected module, found {:?}", self.local_def_id(id)),
} }
} }

View file

@ -1254,15 +1254,13 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
// code uses it). However, we skip encoding anything relating to child // code uses it). However, we skip encoding anything relating to child
// items - we encode information about proc-macros later on. // items - we encode information about proc-macros later on.
let reexports = if !self.is_proc_macro { let reexports = if !self.is_proc_macro {
match tcx.module_reexports(local_def_id) { tcx.module_reexports(local_def_id).unwrap_or(&[])
Some(exports) => self.lazy_array(exports),
_ => LazyArray::empty(),
}
} else { } else {
LazyArray::empty() &[]
}; };
record!(self.tables.kind[def_id] <- EntryKind::Mod(reexports)); record_array!(self.tables.module_reexports[def_id] <- reexports);
record!(self.tables.kind[def_id] <- EntryKind::Mod);
if self.is_proc_macro { if self.is_proc_macro {
// Encode this here because we don't do it in encode_def_ids. // 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)); record!(self.tables.expn_that_defined[def_id] <- tcx.expn_that_defined(local_def_id));

View file

@ -399,6 +399,7 @@ define_tables! {
proc_macro: Table<DefIndex, MacroKind>, proc_macro: Table<DefIndex, MacroKind>,
// Slot is full when there is a self parameter. // Slot is full when there is a self parameter.
fn_has_self_parameter: Table<DefIndex, ()>, fn_has_self_parameter: Table<DefIndex, ()>,
module_reexports: Table<DefIndex, LazyArray<ModChild>>,
} }
#[derive(Copy, Clone, MetadataEncodable, MetadataDecodable)] #[derive(Copy, Clone, MetadataEncodable, MetadataDecodable)]
@ -421,7 +422,7 @@ enum EntryKind {
Union, Union,
Fn, Fn,
ForeignFn, ForeignFn,
Mod(LazyArray<ModChild>), Mod,
MacroDef, MacroDef,
ProcMacro, ProcMacro,
Closure, Closure,