Add generator_kind table.

This commit is contained in:
Camille GILLOT 2022-02-18 19:34:24 +01:00
parent 381d32e7d6
commit 7afcf9fcd1
4 changed files with 5 additions and 10 deletions

View File

@ -1439,13 +1439,6 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
}
}
fn generator_kind(self, id: DefIndex) -> Option<hir::GeneratorKind> {
match self.kind(id) {
EntryKind::Generator(data) => Some(data),
_ => None,
}
}
#[inline]
fn def_key(self, index: DefIndex) -> DefKey {
*self

View File

@ -140,6 +140,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
rendered_const => { table }
asyncness => { table }
fn_arg_names => { table }
generator_kind => { table }
trait_def => { cdata.get_trait_def(def_id.index, tcx.sess) }
adt_def => { cdata.get_adt_def(def_id.index, tcx) }
@ -153,7 +154,6 @@ provide! { <'tcx> tcx, def_id, other, cdata,
is_const_fn_raw => { cdata.is_const_fn_raw(def_id.index) }
is_foreign_item => { cdata.is_foreign_item(def_id.index) }
static_mutability => { cdata.static_mutability(def_id.index) }
generator_kind => { cdata.generator_kind(def_id.index) }
item_attrs => { tcx.arena.alloc_from_iter(cdata.get_item_attrs(def_id.index, tcx.sess)) }
trait_of_item => { cdata.get_trait_of_item(def_id.index) }
is_mir_available => { cdata.is_item_mir_available(def_id.index) }

View File

@ -1569,7 +1569,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
match ty.kind() {
ty::Generator(..) => {
let data = self.tcx.generator_kind(def_id).unwrap();
record!(self.tables.kind[def_id.to_def_id()] <- EntryKind::Generator(data));
record!(self.tables.kind[def_id.to_def_id()] <- EntryKind::Generator);
record!(self.tables.generator_kind[def_id.to_def_id()] <- data);
}
ty::Closure(..) => {

View File

@ -312,6 +312,7 @@ define_tables! {
rendered_const: Table<DefIndex, Lazy!(String)>,
asyncness: Table<DefIndex, Lazy!(hir::IsAsync)>,
fn_arg_names: Table<DefIndex, Lazy!([Ident])>,
generator_kind: Table<DefIndex, Lazy!(hir::GeneratorKind)>,
trait_item_def_id: Table<DefIndex, Lazy<DefId>>,
inherent_impls: Table<DefIndex, Lazy<[DefIndex]>>,
@ -352,7 +353,7 @@ enum EntryKind {
MacroDef(Lazy<MacroDef>),
ProcMacro(MacroKind),
Closure,
Generator(hir::GeneratorKind),
Generator,
Trait(Lazy<TraitData>),
Impl,
AssocFn(Lazy<AssocFnData>),