Add asyncness table.
This commit is contained in:
parent
7bacdb760f
commit
6cc96a45ac
4 changed files with 7 additions and 19 deletions
|
@ -1431,15 +1431,6 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
|
||||||
constness == hir::Constness::Const
|
constness == hir::Constness::Const
|
||||||
}
|
}
|
||||||
|
|
||||||
fn asyncness(self, id: DefIndex) -> hir::IsAsync {
|
|
||||||
match self.kind(id) {
|
|
||||||
EntryKind::Fn(data) => data.decode(self).asyncness,
|
|
||||||
EntryKind::AssocFn(data) => data.decode(self).fn_data.asyncness,
|
|
||||||
EntryKind::ForeignFn(data) => data.decode(self).asyncness,
|
|
||||||
_ => bug!("asyncness: expected function kind"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn is_foreign_item(self, id: DefIndex) -> bool {
|
fn is_foreign_item(self, id: DefIndex) -> bool {
|
||||||
match self.kind(id) {
|
match self.kind(id) {
|
||||||
EntryKind::ForeignImmStatic | EntryKind::ForeignMutStatic | EntryKind::ForeignFn(_) => {
|
EntryKind::ForeignImmStatic | EntryKind::ForeignMutStatic | EntryKind::ForeignFn(_) => {
|
||||||
|
|
|
@ -138,6 +138,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
|
||||||
coerce_unsized_info => { table }
|
coerce_unsized_info => { table }
|
||||||
mir_const_qualif => { table }
|
mir_const_qualif => { table }
|
||||||
rendered_const => { table }
|
rendered_const => { table }
|
||||||
|
asyncness => { table }
|
||||||
|
|
||||||
trait_def => { cdata.get_trait_def(def_id.index, tcx.sess) }
|
trait_def => { cdata.get_trait_def(def_id.index, tcx.sess) }
|
||||||
adt_def => { cdata.get_adt_def(def_id.index, tcx) }
|
adt_def => { cdata.get_adt_def(def_id.index, tcx) }
|
||||||
|
@ -149,7 +150,6 @@ provide! { <'tcx> tcx, def_id, other, cdata,
|
||||||
associated_item => { cdata.get_associated_item(def_id.index) }
|
associated_item => { cdata.get_associated_item(def_id.index) }
|
||||||
inherent_impls => { cdata.get_inherent_implementations_for_type(tcx, def_id.index) }
|
inherent_impls => { cdata.get_inherent_implementations_for_type(tcx, def_id.index) }
|
||||||
is_const_fn_raw => { cdata.is_const_fn_raw(def_id.index) }
|
is_const_fn_raw => { cdata.is_const_fn_raw(def_id.index) }
|
||||||
asyncness => { cdata.asyncness(def_id.index) }
|
|
||||||
is_foreign_item => { cdata.is_foreign_item(def_id.index) }
|
is_foreign_item => { cdata.is_foreign_item(def_id.index) }
|
||||||
static_mutability => { cdata.static_mutability(def_id.index) }
|
static_mutability => { cdata.static_mutability(def_id.index) }
|
||||||
generator_kind => { cdata.generator_kind(def_id.index) }
|
generator_kind => { cdata.generator_kind(def_id.index) }
|
||||||
|
|
|
@ -1199,11 +1199,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||||
hir::TraitFn::Required(ref names) => self.encode_fn_param_names(names),
|
hir::TraitFn::Required(ref names) => self.encode_fn_param_names(names),
|
||||||
hir::TraitFn::Provided(body) => self.encode_fn_param_names_for_body(body),
|
hir::TraitFn::Provided(body) => self.encode_fn_param_names_for_body(body),
|
||||||
};
|
};
|
||||||
FnData {
|
record!(self.tables.asyncness[def_id] <- m_sig.header.asyncness);
|
||||||
asyncness: m_sig.header.asyncness,
|
FnData { constness: hir::Constness::NotConst, param_names }
|
||||||
constness: hir::Constness::NotConst,
|
|
||||||
param_names,
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
bug!()
|
bug!()
|
||||||
};
|
};
|
||||||
|
@ -1264,8 +1261,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
ty::AssocKind::Fn => {
|
ty::AssocKind::Fn => {
|
||||||
let fn_data = if let hir::ImplItemKind::Fn(ref sig, body) = ast_item.kind {
|
let fn_data = if let hir::ImplItemKind::Fn(ref sig, body) = ast_item.kind {
|
||||||
|
record!(self.tables.asyncness[def_id] <- sig.header.asyncness);
|
||||||
FnData {
|
FnData {
|
||||||
asyncness: sig.header.asyncness,
|
|
||||||
// Can be inside `impl const Trait`, so using sig.header.constness is not reliable
|
// Can be inside `impl const Trait`, so using sig.header.constness is not reliable
|
||||||
constness: if self.tcx.is_const_fn_raw(def_id) {
|
constness: if self.tcx.is_const_fn_raw(def_id) {
|
||||||
hir::Constness::Const
|
hir::Constness::Const
|
||||||
|
@ -1407,8 +1404,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||||
EntryKind::Const
|
EntryKind::Const
|
||||||
}
|
}
|
||||||
hir::ItemKind::Fn(ref sig, .., body) => {
|
hir::ItemKind::Fn(ref sig, .., body) => {
|
||||||
|
record!(self.tables.asyncness[def_id] <- sig.header.asyncness);
|
||||||
let data = FnData {
|
let data = FnData {
|
||||||
asyncness: sig.header.asyncness,
|
|
||||||
constness: sig.header.constness,
|
constness: sig.header.constness,
|
||||||
param_names: self.encode_fn_param_names_for_body(body),
|
param_names: self.encode_fn_param_names_for_body(body),
|
||||||
};
|
};
|
||||||
|
@ -1876,8 +1873,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||||
|
|
||||||
match nitem.kind {
|
match nitem.kind {
|
||||||
hir::ForeignItemKind::Fn(_, ref names, _) => {
|
hir::ForeignItemKind::Fn(_, ref names, _) => {
|
||||||
|
record!(self.tables.asyncness[def_id] <- hir::IsAsync::NotAsync);
|
||||||
let data = FnData {
|
let data = FnData {
|
||||||
asyncness: hir::IsAsync::NotAsync,
|
|
||||||
constness: if self.tcx.is_const_fn_raw(def_id) {
|
constness: if self.tcx.is_const_fn_raw(def_id) {
|
||||||
hir::Constness::Const
|
hir::Constness::Const
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -310,6 +310,7 @@ define_tables! {
|
||||||
coerce_unsized_info: Table<DefIndex, Lazy!(ty::adjustment::CoerceUnsizedInfo)>,
|
coerce_unsized_info: Table<DefIndex, Lazy!(ty::adjustment::CoerceUnsizedInfo)>,
|
||||||
mir_const_qualif: Table<DefIndex, Lazy!(mir::ConstQualifs)>,
|
mir_const_qualif: Table<DefIndex, Lazy!(mir::ConstQualifs)>,
|
||||||
rendered_const: Table<DefIndex, Lazy!(String)>,
|
rendered_const: Table<DefIndex, Lazy!(String)>,
|
||||||
|
asyncness: Table<DefIndex, Lazy!(hir::IsAsync)>,
|
||||||
|
|
||||||
trait_item_def_id: Table<DefIndex, Lazy<DefId>>,
|
trait_item_def_id: Table<DefIndex, Lazy<DefId>>,
|
||||||
inherent_impls: Table<DefIndex, Lazy<[DefIndex]>>,
|
inherent_impls: Table<DefIndex, Lazy<[DefIndex]>>,
|
||||||
|
@ -361,7 +362,6 @@ enum EntryKind {
|
||||||
|
|
||||||
#[derive(MetadataEncodable, MetadataDecodable)]
|
#[derive(MetadataEncodable, MetadataDecodable)]
|
||||||
struct FnData {
|
struct FnData {
|
||||||
asyncness: hir::IsAsync,
|
|
||||||
constness: hir::Constness,
|
constness: hir::Constness,
|
||||||
param_names: Lazy<[Ident]>,
|
param_names: Lazy<[Ident]>,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue