mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-04 02:54:00 +00:00
Add asyncness table.
This commit is contained in:
parent
7bacdb760f
commit
6cc96a45ac
@ -1431,15 +1431,6 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
|
||||
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 {
|
||||
match self.kind(id) {
|
||||
EntryKind::ForeignImmStatic | EntryKind::ForeignMutStatic | EntryKind::ForeignFn(_) => {
|
||||
|
@ -138,6 +138,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
|
||||
coerce_unsized_info => { table }
|
||||
mir_const_qualif => { table }
|
||||
rendered_const => { table }
|
||||
asyncness => { table }
|
||||
|
||||
trait_def => { cdata.get_trait_def(def_id.index, tcx.sess) }
|
||||
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) }
|
||||
inherent_impls => { cdata.get_inherent_implementations_for_type(tcx, 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) }
|
||||
static_mutability => { cdata.static_mutability(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::Provided(body) => self.encode_fn_param_names_for_body(body),
|
||||
};
|
||||
FnData {
|
||||
asyncness: m_sig.header.asyncness,
|
||||
constness: hir::Constness::NotConst,
|
||||
param_names,
|
||||
}
|
||||
record!(self.tables.asyncness[def_id] <- m_sig.header.asyncness);
|
||||
FnData { constness: hir::Constness::NotConst, param_names }
|
||||
} else {
|
||||
bug!()
|
||||
};
|
||||
@ -1264,8 +1261,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
}
|
||||
ty::AssocKind::Fn => {
|
||||
let fn_data = if let hir::ImplItemKind::Fn(ref sig, body) = ast_item.kind {
|
||||
record!(self.tables.asyncness[def_id] <- sig.header.asyncness);
|
||||
FnData {
|
||||
asyncness: sig.header.asyncness,
|
||||
// Can be inside `impl const Trait`, so using sig.header.constness is not reliable
|
||||
constness: if self.tcx.is_const_fn_raw(def_id) {
|
||||
hir::Constness::Const
|
||||
@ -1407,8 +1404,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
EntryKind::Const
|
||||
}
|
||||
hir::ItemKind::Fn(ref sig, .., body) => {
|
||||
record!(self.tables.asyncness[def_id] <- sig.header.asyncness);
|
||||
let data = FnData {
|
||||
asyncness: sig.header.asyncness,
|
||||
constness: sig.header.constness,
|
||||
param_names: self.encode_fn_param_names_for_body(body),
|
||||
};
|
||||
@ -1876,8 +1873,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
|
||||
match nitem.kind {
|
||||
hir::ForeignItemKind::Fn(_, ref names, _) => {
|
||||
record!(self.tables.asyncness[def_id] <- hir::IsAsync::NotAsync);
|
||||
let data = FnData {
|
||||
asyncness: hir::IsAsync::NotAsync,
|
||||
constness: if self.tcx.is_const_fn_raw(def_id) {
|
||||
hir::Constness::Const
|
||||
} else {
|
||||
|
@ -310,6 +310,7 @@ define_tables! {
|
||||
coerce_unsized_info: Table<DefIndex, Lazy!(ty::adjustment::CoerceUnsizedInfo)>,
|
||||
mir_const_qualif: Table<DefIndex, Lazy!(mir::ConstQualifs)>,
|
||||
rendered_const: Table<DefIndex, Lazy!(String)>,
|
||||
asyncness: Table<DefIndex, Lazy!(hir::IsAsync)>,
|
||||
|
||||
trait_item_def_id: Table<DefIndex, Lazy<DefId>>,
|
||||
inherent_impls: Table<DefIndex, Lazy<[DefIndex]>>,
|
||||
@ -361,7 +362,6 @@ enum EntryKind {
|
||||
|
||||
#[derive(MetadataEncodable, MetadataDecodable)]
|
||||
struct FnData {
|
||||
asyncness: hir::IsAsync,
|
||||
constness: hir::Constness,
|
||||
param_names: Lazy<[Ident]>,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user