Skip to content

Commit 6cc96a4

Browse files
committed
Add asyncness table.
1 parent 7bacdb7 commit 6cc96a4

File tree

4 files changed

+7
-19
lines changed

4 files changed

+7
-19
lines changed

compiler/rustc_metadata/src/rmeta/decoder.rs

-9
Original file line numberDiff line numberDiff line change
@@ -1431,15 +1431,6 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
14311431
constness == hir::Constness::Const
14321432
}
14331433

1434-
fn asyncness(self, id: DefIndex) -> hir::IsAsync {
1435-
match self.kind(id) {
1436-
EntryKind::Fn(data) => data.decode(self).asyncness,
1437-
EntryKind::AssocFn(data) => data.decode(self).fn_data.asyncness,
1438-
EntryKind::ForeignFn(data) => data.decode(self).asyncness,
1439-
_ => bug!("asyncness: expected function kind"),
1440-
}
1441-
}
1442-
14431434
fn is_foreign_item(self, id: DefIndex) -> bool {
14441435
match self.kind(id) {
14451436
EntryKind::ForeignImmStatic | EntryKind::ForeignMutStatic | EntryKind::ForeignFn(_) => {

compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
138138
coerce_unsized_info => { table }
139139
mir_const_qualif => { table }
140140
rendered_const => { table }
141+
asyncness => { table }
141142

142143
trait_def => { cdata.get_trait_def(def_id.index, tcx.sess) }
143144
adt_def => { cdata.get_adt_def(def_id.index, tcx) }
@@ -149,7 +150,6 @@ provide! { <'tcx> tcx, def_id, other, cdata,
149150
associated_item => { cdata.get_associated_item(def_id.index) }
150151
inherent_impls => { cdata.get_inherent_implementations_for_type(tcx, def_id.index) }
151152
is_const_fn_raw => { cdata.is_const_fn_raw(def_id.index) }
152-
asyncness => { cdata.asyncness(def_id.index) }
153153
is_foreign_item => { cdata.is_foreign_item(def_id.index) }
154154
static_mutability => { cdata.static_mutability(def_id.index) }
155155
generator_kind => { cdata.generator_kind(def_id.index) }

compiler/rustc_metadata/src/rmeta/encoder.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -1199,11 +1199,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
11991199
hir::TraitFn::Required(ref names) => self.encode_fn_param_names(names),
12001200
hir::TraitFn::Provided(body) => self.encode_fn_param_names_for_body(body),
12011201
};
1202-
FnData {
1203-
asyncness: m_sig.header.asyncness,
1204-
constness: hir::Constness::NotConst,
1205-
param_names,
1206-
}
1202+
record!(self.tables.asyncness[def_id] <- m_sig.header.asyncness);
1203+
FnData { constness: hir::Constness::NotConst, param_names }
12071204
} else {
12081205
bug!()
12091206
};
@@ -1264,8 +1261,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
12641261
}
12651262
ty::AssocKind::Fn => {
12661263
let fn_data = if let hir::ImplItemKind::Fn(ref sig, body) = ast_item.kind {
1264+
record!(self.tables.asyncness[def_id] <- sig.header.asyncness);
12671265
FnData {
1268-
asyncness: sig.header.asyncness,
12691266
// Can be inside `impl const Trait`, so using sig.header.constness is not reliable
12701267
constness: if self.tcx.is_const_fn_raw(def_id) {
12711268
hir::Constness::Const
@@ -1407,8 +1404,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
14071404
EntryKind::Const
14081405
}
14091406
hir::ItemKind::Fn(ref sig, .., body) => {
1407+
record!(self.tables.asyncness[def_id] <- sig.header.asyncness);
14101408
let data = FnData {
1411-
asyncness: sig.header.asyncness,
14121409
constness: sig.header.constness,
14131410
param_names: self.encode_fn_param_names_for_body(body),
14141411
};
@@ -1876,8 +1873,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
18761873

18771874
match nitem.kind {
18781875
hir::ForeignItemKind::Fn(_, ref names, _) => {
1876+
record!(self.tables.asyncness[def_id] <- hir::IsAsync::NotAsync);
18791877
let data = FnData {
1880-
asyncness: hir::IsAsync::NotAsync,
18811878
constness: if self.tcx.is_const_fn_raw(def_id) {
18821879
hir::Constness::Const
18831880
} else {

compiler/rustc_metadata/src/rmeta/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ define_tables! {
310310
coerce_unsized_info: Table<DefIndex, Lazy!(ty::adjustment::CoerceUnsizedInfo)>,
311311
mir_const_qualif: Table<DefIndex, Lazy!(mir::ConstQualifs)>,
312312
rendered_const: Table<DefIndex, Lazy!(String)>,
313+
asyncness: Table<DefIndex, Lazy!(hir::IsAsync)>,
313314

314315
trait_item_def_id: Table<DefIndex, Lazy<DefId>>,
315316
inherent_impls: Table<DefIndex, Lazy<[DefIndex]>>,
@@ -361,7 +362,6 @@ enum EntryKind {
361362

362363
#[derive(MetadataEncodable, MetadataDecodable)]
363364
struct FnData {
364-
asyncness: hir::IsAsync,
365365
constness: hir::Constness,
366366
param_names: Lazy<[Ident]>,
367367
}

0 commit comments

Comments
 (0)