diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2022-02-18 19:15:48 +0100 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2022-02-19 15:41:41 +0100 |
| commit | 6cc96a45acfc2bf0af1942439c00adebf64c0ac5 (patch) | |
| tree | 429ebfefcfcf4e81a3bf7cd0c93cc3b3c604995e /compiler/rustc_metadata/src | |
| parent | 7bacdb760f18265b3a5d05406bf2cabb1d33bb5a (diff) | |
| download | rust-6cc96a45acfc2bf0af1942439c00adebf64c0ac5.tar.gz rust-6cc96a45acfc2bf0af1942439c00adebf64c0ac5.zip | |
Add asyncness table.
Diffstat (limited to 'compiler/rustc_metadata/src')
| -rw-r--r-- | compiler/rustc_metadata/src/rmeta/decoder.rs | 9 | ||||
| -rw-r--r-- | compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_metadata/src/rmeta/encoder.rs | 13 | ||||
| -rw-r--r-- | compiler/rustc_metadata/src/rmeta/mod.rs | 2 |
4 files changed, 7 insertions, 19 deletions
diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs index 7071a0ee22a..dc4909bbf5c 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder.rs @@ -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(_) => { diff --git a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs index 0a065dc1910..240792a939b 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs @@ -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) } diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index fcb2f3acdd6..7142242aac7 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -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 { diff --git a/compiler/rustc_metadata/src/rmeta/mod.rs b/compiler/rustc_metadata/src/rmeta/mod.rs index c0cfcf3f702..d3d3fc61e4c 100644 --- a/compiler/rustc_metadata/src/rmeta/mod.rs +++ b/compiler/rustc_metadata/src/rmeta/mod.rs @@ -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]>, } |
