Skip to content

Commit

Permalink
Add generator_kind table.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Feb 19, 2022
1 parent 381d32e commit 7afcf9f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 10 deletions.
7 changes: 0 additions & 7 deletions compiler/rustc_metadata/src/rmeta/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand All @@ -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) }
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_metadata/src/rmeta/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(..) => {
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_metadata/src/rmeta/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]>>,
Expand Down Expand Up @@ -352,7 +353,7 @@ enum EntryKind {
MacroDef(Lazy<MacroDef>),
ProcMacro(MacroKind),
Closure,
Generator(hir::GeneratorKind),
Generator,
Trait(Lazy<TraitData>),
Impl,
AssocFn(Lazy<AssocFnData>),
Expand Down

0 comments on commit 7afcf9f

Please sign in to comment.