Encode metadata using queries.
This commit is contained in:
parent
227d912489
commit
f07f1bfc60
4 changed files with 223 additions and 244 deletions
|
@ -11,7 +11,6 @@ use rustc_data_structures::fx::FxHashMap;
|
||||||
use rustc_data_structures::svh::Svh;
|
use rustc_data_structures::svh::Svh;
|
||||||
use rustc_data_structures::sync::{Lock, LockGuard, Lrc, OnceCell};
|
use rustc_data_structures::sync::{Lock, LockGuard, Lrc, OnceCell};
|
||||||
use rustc_data_structures::unhash::UnhashMap;
|
use rustc_data_structures::unhash::UnhashMap;
|
||||||
use rustc_errors::ErrorReported;
|
|
||||||
use rustc_expand::base::{SyntaxExtension, SyntaxExtensionKind};
|
use rustc_expand::base::{SyntaxExtension, SyntaxExtensionKind};
|
||||||
use rustc_expand::proc_macro::{AttrProcMacro, BangProcMacro, ProcMacroDerive};
|
use rustc_expand::proc_macro::{AttrProcMacro, BangProcMacro, ProcMacroDerive};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
|
@ -21,10 +20,12 @@ use rustc_hir::definitions::{DefKey, DefPath, DefPathData, DefPathHash};
|
||||||
use rustc_hir::diagnostic_items::DiagnosticItems;
|
use rustc_hir::diagnostic_items::DiagnosticItems;
|
||||||
use rustc_hir::lang_items;
|
use rustc_hir::lang_items;
|
||||||
use rustc_index::vec::{Idx, IndexVec};
|
use rustc_index::vec::{Idx, IndexVec};
|
||||||
|
use rustc_middle::arena::ArenaAllocatable;
|
||||||
use rustc_middle::metadata::ModChild;
|
use rustc_middle::metadata::ModChild;
|
||||||
use rustc_middle::middle::exported_symbols::{ExportedSymbol, SymbolExportLevel};
|
use rustc_middle::middle::exported_symbols::{ExportedSymbol, SymbolExportLevel};
|
||||||
|
use rustc_middle::middle::stability::DeprecationEntry;
|
||||||
|
use rustc_middle::mir;
|
||||||
use rustc_middle::mir::interpret::{AllocDecodingSession, AllocDecodingState};
|
use rustc_middle::mir::interpret::{AllocDecodingSession, AllocDecodingState};
|
||||||
use rustc_middle::mir::{self, Body, Promoted};
|
|
||||||
use rustc_middle::thir;
|
use rustc_middle::thir;
|
||||||
use rustc_middle::ty::codec::TyDecoder;
|
use rustc_middle::ty::codec::TyDecoder;
|
||||||
use rustc_middle::ty::fast_reject::SimplifiedType;
|
use rustc_middle::ty::fast_reject::SimplifiedType;
|
||||||
|
@ -278,6 +279,99 @@ impl<'a: 'x, 'tcx: 'x, 'x, T: Decodable<DecodeContext<'a, 'tcx>>> Lazy<[T]> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trait LazyQueryDecodable<'a, 'tcx, T> {
|
||||||
|
fn decode_query(
|
||||||
|
self,
|
||||||
|
cdata: CrateMetadataRef<'a>,
|
||||||
|
tcx: TyCtxt<'tcx>,
|
||||||
|
err: impl FnOnce() -> !,
|
||||||
|
) -> T;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, 'tcx, T> LazyQueryDecodable<'a, 'tcx, T> for Option<Lazy<T>>
|
||||||
|
where
|
||||||
|
T: Decodable<DecodeContext<'a, 'tcx>>,
|
||||||
|
{
|
||||||
|
fn decode_query(
|
||||||
|
self,
|
||||||
|
cdata: CrateMetadataRef<'a>,
|
||||||
|
tcx: TyCtxt<'tcx>,
|
||||||
|
err: impl FnOnce() -> !,
|
||||||
|
) -> T {
|
||||||
|
if let Some(l) = self { l.decode((cdata, tcx)) } else { err() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, 'tcx, T> LazyQueryDecodable<'a, 'tcx, &'tcx T> for Option<Lazy<T>>
|
||||||
|
where
|
||||||
|
T: Decodable<DecodeContext<'a, 'tcx>>,
|
||||||
|
T: ArenaAllocatable<'tcx>,
|
||||||
|
{
|
||||||
|
fn decode_query(
|
||||||
|
self,
|
||||||
|
cdata: CrateMetadataRef<'a>,
|
||||||
|
tcx: TyCtxt<'tcx>,
|
||||||
|
err: impl FnOnce() -> !,
|
||||||
|
) -> &'tcx T {
|
||||||
|
if let Some(l) = self { tcx.arena.alloc(l.decode((cdata, tcx))) } else { err() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, 'tcx, T> LazyQueryDecodable<'a, 'tcx, Option<T>> for Option<Lazy<T>>
|
||||||
|
where
|
||||||
|
T: Decodable<DecodeContext<'a, 'tcx>>,
|
||||||
|
{
|
||||||
|
fn decode_query(
|
||||||
|
self,
|
||||||
|
cdata: CrateMetadataRef<'a>,
|
||||||
|
tcx: TyCtxt<'tcx>,
|
||||||
|
_err: impl FnOnce() -> !,
|
||||||
|
) -> Option<T> {
|
||||||
|
self.map(|l| l.decode((cdata, tcx)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, 'tcx, T, E> LazyQueryDecodable<'a, 'tcx, Result<Option<T>, E>> for Option<Lazy<T>>
|
||||||
|
where
|
||||||
|
T: Decodable<DecodeContext<'a, 'tcx>>,
|
||||||
|
{
|
||||||
|
fn decode_query(
|
||||||
|
self,
|
||||||
|
cdata: CrateMetadataRef<'a>,
|
||||||
|
tcx: TyCtxt<'tcx>,
|
||||||
|
_err: impl FnOnce() -> !,
|
||||||
|
) -> Result<Option<T>, E> {
|
||||||
|
Ok(self.map(|l| l.decode((cdata, tcx))))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, 'tcx, T> LazyQueryDecodable<'a, 'tcx, &'tcx [T]> for Option<Lazy<[T], usize>>
|
||||||
|
where
|
||||||
|
T: Decodable<DecodeContext<'a, 'tcx>> + Copy,
|
||||||
|
{
|
||||||
|
fn decode_query(
|
||||||
|
self,
|
||||||
|
cdata: CrateMetadataRef<'a>,
|
||||||
|
tcx: TyCtxt<'tcx>,
|
||||||
|
_err: impl FnOnce() -> !,
|
||||||
|
) -> &'tcx [T] {
|
||||||
|
if let Some(l) = self { tcx.arena.alloc_from_iter(l.decode((cdata, tcx))) } else { &[] }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, 'tcx> LazyQueryDecodable<'a, 'tcx, Option<DeprecationEntry>>
|
||||||
|
for Option<Lazy<attr::Deprecation>>
|
||||||
|
{
|
||||||
|
fn decode_query(
|
||||||
|
self,
|
||||||
|
cdata: CrateMetadataRef<'a>,
|
||||||
|
tcx: TyCtxt<'tcx>,
|
||||||
|
_err: impl FnOnce() -> !,
|
||||||
|
) -> Option<DeprecationEntry> {
|
||||||
|
self.map(|l| l.decode((cdata, tcx))).map(DeprecationEntry::external)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> DecodeContext<'a, 'tcx> {
|
impl<'a, 'tcx> DecodeContext<'a, 'tcx> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn tcx(&self) -> TyCtxt<'tcx> {
|
fn tcx(&self) -> TyCtxt<'tcx> {
|
||||||
|
@ -716,7 +810,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
|
||||||
|
|
||||||
fn opt_item_ident(self, item_index: DefIndex, sess: &Session) -> Option<Ident> {
|
fn opt_item_ident(self, item_index: DefIndex, sess: &Session) -> Option<Ident> {
|
||||||
let name = self.def_key(item_index).disambiguated_data.data.get_opt_name()?;
|
let name = self.def_key(item_index).disambiguated_data.data.get_opt_name()?;
|
||||||
let span = match self.root.tables.ident_span.get(self, item_index) {
|
let span = match self.root.tables.def_ident_span.get(self, item_index) {
|
||||||
Some(lazy_span) => lazy_span.decode((self, sess)),
|
Some(lazy_span) => lazy_span.decode((self, sess)),
|
||||||
None => {
|
None => {
|
||||||
// FIXME: this weird case of a name with no span is specific to `extern crate`
|
// FIXME: this weird case of a name with no span is specific to `extern crate`
|
||||||
|
@ -750,20 +844,22 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn def_kind(self, item_id: DefIndex) -> DefKind {
|
fn def_kind(self, item_id: DefIndex) -> DefKind {
|
||||||
self.root.tables.def_kind.get(self, item_id).map(|k| k.decode(self)).unwrap_or_else(|| {
|
self.root.tables.opt_def_kind.get(self, item_id).map(|k| k.decode(self)).unwrap_or_else(
|
||||||
bug!(
|
|| {
|
||||||
"CrateMetadata::def_kind({:?}): id not found, in crate {:?} with number {}",
|
bug!(
|
||||||
item_id,
|
"CrateMetadata::def_kind({:?}): id not found, in crate {:?} with number {}",
|
||||||
self.root.name,
|
item_id,
|
||||||
self.cnum,
|
self.root.name,
|
||||||
)
|
self.cnum,
|
||||||
})
|
)
|
||||||
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_span(self, index: DefIndex, sess: &Session) -> Span {
|
fn get_span(self, index: DefIndex, sess: &Session) -> Span {
|
||||||
self.root
|
self.root
|
||||||
.tables
|
.tables
|
||||||
.span
|
.def_span
|
||||||
.get(self, index)
|
.get(self, index)
|
||||||
.unwrap_or_else(|| panic!("Missing span for {:?}", index))
|
.unwrap_or_else(|| panic!("Missing span for {:?}", index))
|
||||||
.decode((self, sess))
|
.decode((self, sess))
|
||||||
|
@ -908,71 +1004,8 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
|
||||||
tcx.alloc_adt_def(did, adt_kind, variants, repr)
|
tcx.alloc_adt_def(did, adt_kind, variants, repr)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_explicit_predicates(
|
|
||||||
self,
|
|
||||||
item_id: DefIndex,
|
|
||||||
tcx: TyCtxt<'tcx>,
|
|
||||||
) -> ty::GenericPredicates<'tcx> {
|
|
||||||
self.root.tables.explicit_predicates.get(self, item_id).unwrap().decode((self, tcx))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_inferred_outlives(
|
|
||||||
self,
|
|
||||||
item_id: DefIndex,
|
|
||||||
tcx: TyCtxt<'tcx>,
|
|
||||||
) -> &'tcx [(ty::Predicate<'tcx>, Span)] {
|
|
||||||
self.root
|
|
||||||
.tables
|
|
||||||
.inferred_outlives
|
|
||||||
.get(self, item_id)
|
|
||||||
.map(|predicates| tcx.arena.alloc_from_iter(predicates.decode((self, tcx))))
|
|
||||||
.unwrap_or_default()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_super_predicates(
|
|
||||||
self,
|
|
||||||
item_id: DefIndex,
|
|
||||||
tcx: TyCtxt<'tcx>,
|
|
||||||
) -> ty::GenericPredicates<'tcx> {
|
|
||||||
self.root.tables.super_predicates.get(self, item_id).unwrap().decode((self, tcx))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_explicit_item_bounds(
|
|
||||||
self,
|
|
||||||
item_id: DefIndex,
|
|
||||||
tcx: TyCtxt<'tcx>,
|
|
||||||
) -> &'tcx [(ty::Predicate<'tcx>, Span)] {
|
|
||||||
self.root
|
|
||||||
.tables
|
|
||||||
.explicit_item_bounds
|
|
||||||
.get(self, item_id)
|
|
||||||
.map(|bounds| tcx.arena.alloc_from_iter(bounds.decode((self, tcx))))
|
|
||||||
.unwrap_or_default()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_generics(self, item_id: DefIndex, sess: &Session) -> ty::Generics {
|
fn get_generics(self, item_id: DefIndex, sess: &Session) -> ty::Generics {
|
||||||
self.root.tables.generics.get(self, item_id).unwrap().decode((self, sess))
|
self.root.tables.generics_of.get(self, item_id).unwrap().decode((self, sess))
|
||||||
}
|
|
||||||
|
|
||||||
fn get_type(self, id: DefIndex, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
|
|
||||||
self.root
|
|
||||||
.tables
|
|
||||||
.ty
|
|
||||||
.get(self, id)
|
|
||||||
.unwrap_or_else(|| panic!("Not a type: {:?}", id))
|
|
||||||
.decode((self, tcx))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_stability(self, id: DefIndex) -> Option<attr::Stability> {
|
|
||||||
self.root.tables.stability.get(self, id).map(|stab| stab.decode(self))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_const_stability(self, id: DefIndex) -> Option<attr::ConstStability> {
|
|
||||||
self.root.tables.const_stability.get(self, id).map(|stab| stab.decode(self))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_deprecation(self, id: DefIndex) -> Option<attr::Deprecation> {
|
|
||||||
self.root.tables.deprecation.get(self, id).map(|depr| depr.decode(self))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_visibility(self, id: DefIndex) -> ty::Visibility {
|
fn get_visibility(self, id: DefIndex) -> ty::Visibility {
|
||||||
|
@ -1010,22 +1043,10 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
|
||||||
self.get_impl_data(id).coerce_unsized_info
|
self.get_impl_data(id).coerce_unsized_info
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_impl_trait(self, id: DefIndex, tcx: TyCtxt<'tcx>) -> Option<ty::TraitRef<'tcx>> {
|
|
||||||
self.root.tables.impl_trait_ref.get(self, id).map(|tr| tr.decode((self, tcx)))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_expn_that_defined(self, id: DefIndex, sess: &Session) -> ExpnId {
|
fn get_expn_that_defined(self, id: DefIndex, sess: &Session) -> ExpnId {
|
||||||
self.root.tables.expn_that_defined.get(self, id).unwrap().decode((self, sess))
|
self.root.tables.expn_that_defined.get(self, id).unwrap().decode((self, sess))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_const_param_default(
|
|
||||||
self,
|
|
||||||
tcx: TyCtxt<'tcx>,
|
|
||||||
id: DefIndex,
|
|
||||||
) -> rustc_middle::ty::Const<'tcx> {
|
|
||||||
self.root.tables.const_defaults.get(self, id).unwrap().decode((self, tcx))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Iterates over all the stability attributes in the given crate.
|
/// Iterates over all the stability attributes in the given crate.
|
||||||
fn get_lib_features(self, tcx: TyCtxt<'tcx>) -> &'tcx [(Symbol, Option<Symbol>)] {
|
fn get_lib_features(self, tcx: TyCtxt<'tcx>) -> &'tcx [(Symbol, Option<Symbol>)] {
|
||||||
tcx.arena.alloc_from_iter(self.root.lib_features.decode(self))
|
tcx.arena.alloc_from_iter(self.root.lib_features.decode(self))
|
||||||
|
@ -1163,7 +1184,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_item_mir_available(self, id: DefIndex) -> bool {
|
fn is_item_mir_available(self, id: DefIndex) -> bool {
|
||||||
self.root.tables.mir.get(self, id).is_some()
|
self.root.tables.optimized_mir.get(self, id).is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn module_expansion(self, id: DefIndex, sess: &Session) -> ExpnId {
|
fn module_expansion(self, id: DefIndex, sess: &Session) -> ExpnId {
|
||||||
|
@ -1175,60 +1196,6 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_optimized_mir(self, tcx: TyCtxt<'tcx>, id: DefIndex) -> Body<'tcx> {
|
|
||||||
self.root
|
|
||||||
.tables
|
|
||||||
.mir
|
|
||||||
.get(self, id)
|
|
||||||
.unwrap_or_else(|| {
|
|
||||||
bug!("get_optimized_mir: missing MIR for `{:?}`", self.local_def_id(id))
|
|
||||||
})
|
|
||||||
.decode((self, tcx))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_mir_for_ctfe(self, tcx: TyCtxt<'tcx>, id: DefIndex) -> Body<'tcx> {
|
|
||||||
self.root
|
|
||||||
.tables
|
|
||||||
.mir_for_ctfe
|
|
||||||
.get(self, id)
|
|
||||||
.unwrap_or_else(|| {
|
|
||||||
bug!("get_mir_for_ctfe: missing MIR for `{:?}`", self.local_def_id(id))
|
|
||||||
})
|
|
||||||
.decode((self, tcx))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_thir_abstract_const(
|
|
||||||
self,
|
|
||||||
tcx: TyCtxt<'tcx>,
|
|
||||||
id: DefIndex,
|
|
||||||
) -> Result<Option<&'tcx [thir::abstract_const::Node<'tcx>]>, ErrorReported> {
|
|
||||||
self.root
|
|
||||||
.tables
|
|
||||||
.thir_abstract_consts
|
|
||||||
.get(self, id)
|
|
||||||
.map_or(Ok(None), |v| Ok(Some(v.decode((self, tcx)))))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_unused_generic_params(self, id: DefIndex) -> FiniteBitSet<u32> {
|
|
||||||
self.root
|
|
||||||
.tables
|
|
||||||
.unused_generic_params
|
|
||||||
.get(self, id)
|
|
||||||
.map(|params| params.decode(self))
|
|
||||||
.unwrap_or_default()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_promoted_mir(self, tcx: TyCtxt<'tcx>, id: DefIndex) -> IndexVec<Promoted, Body<'tcx>> {
|
|
||||||
self.root
|
|
||||||
.tables
|
|
||||||
.promoted_mir
|
|
||||||
.get(self, id)
|
|
||||||
.unwrap_or_else(|| {
|
|
||||||
bug!("get_promoted_mir: missing MIR for `{:?}`", self.local_def_id(id))
|
|
||||||
})
|
|
||||||
.decode((self, tcx))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn mir_const_qualif(self, id: DefIndex) -> mir::ConstQualifs {
|
fn mir_const_qualif(self, id: DefIndex) -> mir::ConstQualifs {
|
||||||
match self.kind(id) {
|
match self.kind(id) {
|
||||||
EntryKind::AnonConst(qualif, _)
|
EntryKind::AnonConst(qualif, _)
|
||||||
|
@ -1288,10 +1255,6 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_item_variances(self, id: DefIndex) -> impl Iterator<Item = ty::Variance> + 'a {
|
|
||||||
self.root.tables.variances.get(self, id).unwrap_or_else(Lazy::empty).decode(self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_ctor_def_id_and_kind(self, node_id: DefIndex) -> Option<(DefId, CtorKind)> {
|
fn get_ctor_def_id_and_kind(self, node_id: DefIndex) -> Option<(DefId, CtorKind)> {
|
||||||
match self.kind(node_id) {
|
match self.kind(node_id) {
|
||||||
EntryKind::Struct(data, _) | EntryKind::Variant(data) => {
|
EntryKind::Struct(data, _) | EntryKind::Variant(data) => {
|
||||||
|
@ -1479,7 +1442,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
|
||||||
EntryKind::AssocFn(data) => data.decode(self).fn_data.param_names,
|
EntryKind::AssocFn(data) => data.decode(self).fn_data.param_names,
|
||||||
_ => Lazy::empty(),
|
_ => Lazy::empty(),
|
||||||
};
|
};
|
||||||
tcx.arena.alloc_from_iter(param_names.decode((self, tcx)))
|
LazyQueryDecodable::decode_query(Some(param_names), self, tcx, || unreachable!())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn exported_symbols(
|
fn exported_symbols(
|
||||||
|
@ -1551,10 +1514,6 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fn_sig(self, id: DefIndex, tcx: TyCtxt<'tcx>) -> ty::PolyFnSig<'tcx> {
|
|
||||||
self.root.tables.fn_sig.get(self, id).unwrap().decode((self, tcx))
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn def_key(self, index: DefIndex) -> DefKey {
|
fn def_key(self, index: DefIndex) -> DefKey {
|
||||||
*self
|
*self
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
use super::LazyQueryDecodable;
|
||||||
use crate::creader::{CStore, LoadedMacro};
|
use crate::creader::{CStore, LoadedMacro};
|
||||||
use crate::foreign_modules;
|
use crate::foreign_modules;
|
||||||
use crate::native_libs;
|
use crate::native_libs;
|
||||||
|
@ -8,7 +9,6 @@ use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, CRATE_DEF_INDEX, LOCAL_CRATE}
|
||||||
use rustc_hir::definitions::{DefKey, DefPath, DefPathHash};
|
use rustc_hir::definitions::{DefKey, DefPath, DefPathHash};
|
||||||
use rustc_middle::metadata::ModChild;
|
use rustc_middle::metadata::ModChild;
|
||||||
use rustc_middle::middle::exported_symbols::ExportedSymbol;
|
use rustc_middle::middle::exported_symbols::ExportedSymbol;
|
||||||
use rustc_middle::middle::stability::DeprecationEntry;
|
|
||||||
use rustc_middle::ty::fast_reject::SimplifiedType;
|
use rustc_middle::ty::fast_reject::SimplifiedType;
|
||||||
use rustc_middle::ty::query::{ExternProviders, Providers};
|
use rustc_middle::ty::query::{ExternProviders, Providers};
|
||||||
use rustc_middle::ty::{self, TyCtxt, Visibility};
|
use rustc_middle::ty::{self, TyCtxt, Visibility};
|
||||||
|
@ -23,32 +23,51 @@ use rustc_data_structures::sync::Lrc;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
|
|
||||||
|
macro_rules! provide_one {
|
||||||
|
(<$lt:tt> $tcx:ident, $def_id:ident, $other:ident, $cdata:ident, $name:ident => { table }) => {
|
||||||
|
provide_one! {
|
||||||
|
<$lt> $tcx, $def_id, $other, $cdata, $name => {
|
||||||
|
$cdata.root.tables.$name.get($cdata, $def_id.index).decode_query(
|
||||||
|
$cdata,
|
||||||
|
$tcx,
|
||||||
|
|| panic!("{:?} does not have a {:?}", $def_id, stringify!($name)),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
(<$lt:tt> $tcx:ident, $def_id:ident, $other:ident, $cdata:ident, $name:ident => $compute:block) => {
|
||||||
|
fn $name<$lt>(
|
||||||
|
$tcx: TyCtxt<$lt>,
|
||||||
|
def_id_arg: ty::query::query_keys::$name<$lt>,
|
||||||
|
) -> ty::query::query_values::$name<$lt> {
|
||||||
|
let _prof_timer =
|
||||||
|
$tcx.prof.generic_activity(concat!("metadata_decode_entry_", stringify!($name)));
|
||||||
|
|
||||||
|
#[allow(unused_variables)]
|
||||||
|
let ($def_id, $other) = def_id_arg.into_args();
|
||||||
|
assert!(!$def_id.is_local());
|
||||||
|
|
||||||
|
// External query providers call `crate_hash` in order to register a dependency
|
||||||
|
// on the crate metadata. The exception is `crate_hash` itself, which obviously
|
||||||
|
// doesn't need to do this (and can't, as it would cause a query cycle).
|
||||||
|
use rustc_middle::dep_graph::DepKind;
|
||||||
|
if DepKind::$name != DepKind::crate_hash && $tcx.dep_graph.is_fully_enabled() {
|
||||||
|
$tcx.ensure().crate_hash($def_id.krate);
|
||||||
|
}
|
||||||
|
|
||||||
|
let $cdata = CStore::from_tcx($tcx).get_crate_data($def_id.krate);
|
||||||
|
|
||||||
|
$compute
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
macro_rules! provide {
|
macro_rules! provide {
|
||||||
(<$lt:tt> $tcx:ident, $def_id:ident, $other:ident, $cdata:ident,
|
(<$lt:tt> $tcx:ident, $def_id:ident, $other:ident, $cdata:ident,
|
||||||
$($name:ident => $compute:block)*) => {
|
$($name:ident => { $($compute:tt)* })*) => {
|
||||||
pub fn provide_extern(providers: &mut ExternProviders) {
|
pub fn provide_extern(providers: &mut ExternProviders) {
|
||||||
$(fn $name<$lt>(
|
$(provide_one! {
|
||||||
$tcx: TyCtxt<$lt>,
|
<$lt> $tcx, $def_id, $other, $cdata, $name => { $($compute)* }
|
||||||
def_id_arg: ty::query::query_keys::$name<$lt>,
|
|
||||||
) -> ty::query::query_values::$name<$lt> {
|
|
||||||
let _prof_timer =
|
|
||||||
$tcx.prof.generic_activity(concat!("metadata_decode_entry_", stringify!($name)));
|
|
||||||
|
|
||||||
#[allow(unused_variables)]
|
|
||||||
let ($def_id, $other) = def_id_arg.into_args();
|
|
||||||
assert!(!$def_id.is_local());
|
|
||||||
|
|
||||||
// External query providers call `crate_hash` in order to register a dependency
|
|
||||||
// on the crate metadata. The exception is `crate_hash` itself, which obviously
|
|
||||||
// doesn't need to do this (and can't, as it would cause a query cycle).
|
|
||||||
use rustc_middle::dep_graph::DepKind;
|
|
||||||
if DepKind::$name != DepKind::crate_hash && $tcx.dep_graph.is_fully_enabled() {
|
|
||||||
$tcx.ensure().crate_hash($def_id.krate);
|
|
||||||
}
|
|
||||||
|
|
||||||
let $cdata = CStore::from_tcx($tcx).get_crate_data($def_id.krate);
|
|
||||||
|
|
||||||
$compute
|
|
||||||
})*
|
})*
|
||||||
|
|
||||||
*providers = ExternProviders {
|
*providers = ExternProviders {
|
||||||
|
@ -90,50 +109,50 @@ impl<'tcx> IntoArgs for ty::InstanceDef<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
provide! { <'tcx> tcx, def_id, other, cdata,
|
provide! { <'tcx> tcx, def_id, other, cdata,
|
||||||
type_of => { cdata.get_type(def_id.index, tcx) }
|
explicit_item_bounds => { table }
|
||||||
generics_of => { cdata.get_generics(def_id.index, tcx.sess) }
|
explicit_predicates_of => { table }
|
||||||
explicit_predicates_of => { cdata.get_explicit_predicates(def_id.index, tcx) }
|
generics_of => { table }
|
||||||
inferred_outlives_of => { cdata.get_inferred_outlives(def_id.index, tcx) }
|
inferred_outlives_of => { table }
|
||||||
super_predicates_of => { cdata.get_super_predicates(def_id.index, tcx) }
|
super_predicates_of => { table }
|
||||||
explicit_item_bounds => { cdata.get_explicit_item_bounds(def_id.index, tcx) }
|
type_of => { table }
|
||||||
|
variances_of => { table }
|
||||||
|
fn_sig => { table }
|
||||||
|
impl_trait_ref => { table }
|
||||||
|
const_param_default => { table }
|
||||||
|
thir_abstract_const => { table }
|
||||||
|
optimized_mir => { table }
|
||||||
|
mir_for_ctfe => { table }
|
||||||
|
promoted_mir => { table }
|
||||||
|
def_span => { table }
|
||||||
|
def_ident_span => { table }
|
||||||
|
lookup_stability => { table }
|
||||||
|
lookup_const_stability => { table }
|
||||||
|
lookup_deprecation_entry => { table }
|
||||||
|
visibility => { table }
|
||||||
|
unused_generic_params => { table }
|
||||||
|
opt_def_kind => { 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) }
|
||||||
adt_destructor => {
|
adt_destructor => {
|
||||||
let _ = cdata;
|
let _ = cdata;
|
||||||
tcx.calculate_dtor(def_id, |_,_| Ok(()))
|
tcx.calculate_dtor(def_id, |_,_| Ok(()))
|
||||||
}
|
}
|
||||||
variances_of => { tcx.arena.alloc_from_iter(cdata.get_item_variances(def_id.index)) }
|
|
||||||
associated_item_def_ids => { cdata.get_associated_item_def_ids(tcx, def_id.index) }
|
associated_item_def_ids => { cdata.get_associated_item_def_ids(tcx, def_id.index) }
|
||||||
associated_item => { cdata.get_associated_item(def_id.index, tcx.sess) }
|
associated_item => { cdata.get_associated_item(def_id.index, tcx.sess) }
|
||||||
impl_trait_ref => { cdata.get_impl_trait(def_id.index, tcx) }
|
|
||||||
impl_polarity => { cdata.get_impl_polarity(def_id.index) }
|
impl_polarity => { cdata.get_impl_polarity(def_id.index) }
|
||||||
coerce_unsized_info => {
|
coerce_unsized_info => {
|
||||||
cdata.get_coerce_unsized_info(def_id.index).unwrap_or_else(|| {
|
cdata.get_coerce_unsized_info(def_id.index).unwrap_or_else(|| {
|
||||||
bug!("coerce_unsized_info: `{:?}` is missing its info", def_id);
|
bug!("coerce_unsized_info: `{:?}` is missing its info", def_id);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
optimized_mir => { tcx.arena.alloc(cdata.get_optimized_mir(tcx, def_id.index)) }
|
|
||||||
mir_for_ctfe => { tcx.arena.alloc(cdata.get_mir_for_ctfe(tcx, def_id.index)) }
|
|
||||||
promoted_mir => { tcx.arena.alloc(cdata.get_promoted_mir(tcx, def_id.index)) }
|
|
||||||
thir_abstract_const => { cdata.get_thir_abstract_const(tcx, def_id.index) }
|
|
||||||
unused_generic_params => { cdata.get_unused_generic_params(def_id.index) }
|
|
||||||
const_param_default => { cdata.get_const_param_default(tcx, def_id.index) }
|
|
||||||
mir_const_qualif => { cdata.mir_const_qualif(def_id.index) }
|
mir_const_qualif => { cdata.mir_const_qualif(def_id.index) }
|
||||||
fn_sig => { cdata.fn_sig(def_id.index, tcx) }
|
|
||||||
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) }
|
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) }
|
||||||
opt_def_kind => { Some(cdata.def_kind(def_id.index)) }
|
|
||||||
def_span => { cdata.get_span(def_id.index, &tcx.sess) }
|
|
||||||
def_ident_span => { cdata.opt_item_ident(def_id.index, &tcx.sess).map(|ident| ident.span) }
|
|
||||||
lookup_stability => { cdata.get_stability(def_id.index) }
|
|
||||||
lookup_const_stability => { cdata.get_const_stability(def_id.index) }
|
|
||||||
lookup_deprecation_entry => {
|
|
||||||
cdata.get_deprecation(def_id.index).map(DeprecationEntry::external)
|
|
||||||
}
|
|
||||||
item_attrs => { tcx.arena.alloc_from_iter(cdata.get_item_attrs(def_id.index, tcx.sess)) }
|
item_attrs => { tcx.arena.alloc_from_iter(cdata.get_item_attrs(def_id.index, tcx.sess)) }
|
||||||
fn_arg_names => { cdata.get_fn_param_names(tcx, def_id.index) }
|
fn_arg_names => { cdata.get_fn_param_names(tcx, def_id.index) }
|
||||||
rendered_const => { cdata.get_rendered_const(def_id.index) }
|
rendered_const => { cdata.get_rendered_const(def_id.index) }
|
||||||
|
@ -185,7 +204,6 @@ provide! { <'tcx> tcx, def_id, other, cdata,
|
||||||
traits_in_crate => { tcx.arena.alloc_from_iter(cdata.get_traits()) }
|
traits_in_crate => { tcx.arena.alloc_from_iter(cdata.get_traits()) }
|
||||||
implementations_of_trait => { cdata.get_implementations_of_trait(tcx, other) }
|
implementations_of_trait => { cdata.get_implementations_of_trait(tcx, other) }
|
||||||
|
|
||||||
visibility => { cdata.get_visibility(def_id.index) }
|
|
||||||
dep_kind => {
|
dep_kind => {
|
||||||
let r = *cdata.dep_kind.lock();
|
let r = *cdata.dep_kind.lock();
|
||||||
r
|
r
|
||||||
|
|
|
@ -983,13 +983,13 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||||
let def_id = local_id.to_def_id();
|
let def_id = local_id.to_def_id();
|
||||||
let def_kind = tcx.opt_def_kind(local_id);
|
let def_kind = tcx.opt_def_kind(local_id);
|
||||||
let Some(def_kind) = def_kind else { continue };
|
let Some(def_kind) = def_kind else { continue };
|
||||||
record!(self.tables.def_kind[def_id] <- match def_kind {
|
record!(self.tables.opt_def_kind[def_id] <- match def_kind {
|
||||||
// Replace Ctor by the enclosing object to avoid leaking details in children crates.
|
// Replace Ctor by the enclosing object to avoid leaking details in children crates.
|
||||||
DefKind::Ctor(CtorOf::Struct, _) => DefKind::Struct,
|
DefKind::Ctor(CtorOf::Struct, _) => DefKind::Struct,
|
||||||
DefKind::Ctor(CtorOf::Variant, _) => DefKind::Variant,
|
DefKind::Ctor(CtorOf::Variant, _) => DefKind::Variant,
|
||||||
def_kind => def_kind,
|
def_kind => def_kind,
|
||||||
});
|
});
|
||||||
record!(self.tables.span[def_id] <- tcx.def_span(def_id));
|
record!(self.tables.def_span[def_id] <- tcx.def_span(def_id));
|
||||||
record!(self.tables.attributes[def_id] <- tcx.get_attrs(def_id));
|
record!(self.tables.attributes[def_id] <- tcx.get_attrs(def_id));
|
||||||
record!(self.tables.expn_that_defined[def_id] <- self.tcx.expn_that_defined(def_id));
|
record!(self.tables.expn_that_defined[def_id] <- self.tcx.expn_that_defined(def_id));
|
||||||
if should_encode_visibility(def_kind) {
|
if should_encode_visibility(def_kind) {
|
||||||
|
@ -1002,19 +1002,19 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
if should_encode_variances(def_kind) {
|
if should_encode_variances(def_kind) {
|
||||||
let v = self.tcx.variances_of(def_id);
|
let v = self.tcx.variances_of(def_id);
|
||||||
record!(self.tables.variances[def_id] <- v);
|
record!(self.tables.variances_of[def_id] <- v);
|
||||||
}
|
}
|
||||||
if should_encode_generics(def_kind) {
|
if should_encode_generics(def_kind) {
|
||||||
let g = tcx.generics_of(def_id);
|
let g = tcx.generics_of(def_id);
|
||||||
record!(self.tables.generics[def_id] <- g);
|
record!(self.tables.generics_of[def_id] <- g);
|
||||||
record!(self.tables.explicit_predicates[def_id] <- self.tcx.explicit_predicates_of(def_id));
|
record!(self.tables.explicit_predicates_of[def_id] <- self.tcx.explicit_predicates_of(def_id));
|
||||||
let inferred_outlives = self.tcx.inferred_outlives_of(def_id);
|
let inferred_outlives = self.tcx.inferred_outlives_of(def_id);
|
||||||
if !inferred_outlives.is_empty() {
|
if !inferred_outlives.is_empty() {
|
||||||
record!(self.tables.inferred_outlives[def_id] <- inferred_outlives);
|
record!(self.tables.inferred_outlives_of[def_id] <- inferred_outlives);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let DefKind::Trait | DefKind::TraitAlias = def_kind {
|
if let DefKind::Trait | DefKind::TraitAlias = def_kind {
|
||||||
record!(self.tables.super_predicates[def_id] <- self.tcx.super_predicates_of(def_id));
|
record!(self.tables.super_predicates_of[def_id] <- self.tcx.super_predicates_of(def_id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let inherent_impls = tcx.crate_inherent_impls(());
|
let inherent_impls = tcx.crate_inherent_impls(());
|
||||||
|
@ -1031,7 +1031,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||||
|
|
||||||
fn encode_item_type(&mut self, def_id: DefId) {
|
fn encode_item_type(&mut self, def_id: DefId) {
|
||||||
debug!("EncodeContext::encode_item_type({:?})", def_id);
|
debug!("EncodeContext::encode_item_type({:?})", def_id);
|
||||||
record!(self.tables.ty[def_id] <- self.tcx.type_of(def_id));
|
record!(self.tables.type_of[def_id] <- self.tcx.type_of(def_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn encode_enum_variant_info(&mut self, def: &ty::AdtDef, index: VariantIdx) {
|
fn encode_enum_variant_info(&mut self, def: &ty::AdtDef, index: VariantIdx) {
|
||||||
|
@ -1332,7 +1332,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||||
|
|
||||||
debug!("EntryBuilder::encode_mir({:?})", def_id);
|
debug!("EntryBuilder::encode_mir({:?})", def_id);
|
||||||
if encode_opt {
|
if encode_opt {
|
||||||
record!(self.tables.mir[def_id.to_def_id()] <- self.tcx.optimized_mir(def_id));
|
record!(self.tables.optimized_mir[def_id.to_def_id()] <- self.tcx.optimized_mir(def_id));
|
||||||
}
|
}
|
||||||
if encode_const {
|
if encode_const {
|
||||||
record!(self.tables.mir_for_ctfe[def_id.to_def_id()] <- self.tcx.mir_for_ctfe(def_id));
|
record!(self.tables.mir_for_ctfe[def_id.to_def_id()] <- self.tcx.mir_for_ctfe(def_id));
|
||||||
|
@ -1340,7 +1340,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||||
// FIXME(generic_const_exprs): this feels wrong to have in `encode_mir`
|
// FIXME(generic_const_exprs): this feels wrong to have in `encode_mir`
|
||||||
let abstract_const = self.tcx.thir_abstract_const(def_id);
|
let abstract_const = self.tcx.thir_abstract_const(def_id);
|
||||||
if let Ok(Some(abstract_const)) = abstract_const {
|
if let Ok(Some(abstract_const)) = abstract_const {
|
||||||
record!(self.tables.thir_abstract_consts[def_id.to_def_id()] <- abstract_const);
|
record!(self.tables.thir_abstract_const[def_id.to_def_id()] <- abstract_const);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
record!(self.tables.promoted_mir[def_id.to_def_id()] <- self.tcx.promoted_mir(def_id));
|
record!(self.tables.promoted_mir[def_id.to_def_id()] <- self.tcx.promoted_mir(def_id));
|
||||||
|
@ -1361,7 +1361,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||||
// the stability attributes are even enabled before using their queries.
|
// the stability attributes are even enabled before using their queries.
|
||||||
if self.feat.staged_api || self.tcx.sess.opts.debugging_opts.force_unstable_if_unmarked {
|
if self.feat.staged_api || self.tcx.sess.opts.debugging_opts.force_unstable_if_unmarked {
|
||||||
if let Some(stab) = self.tcx.lookup_stability(def_id) {
|
if let Some(stab) = self.tcx.lookup_stability(def_id) {
|
||||||
record!(self.tables.stability[def_id] <- stab)
|
record!(self.tables.lookup_stability[def_id] <- stab)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1373,7 +1373,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||||
// the stability attributes are even enabled before using their queries.
|
// the stability attributes are even enabled before using their queries.
|
||||||
if self.feat.staged_api || self.tcx.sess.opts.debugging_opts.force_unstable_if_unmarked {
|
if self.feat.staged_api || self.tcx.sess.opts.debugging_opts.force_unstable_if_unmarked {
|
||||||
if let Some(stab) = self.tcx.lookup_const_stability(def_id) {
|
if let Some(stab) = self.tcx.lookup_const_stability(def_id) {
|
||||||
record!(self.tables.const_stability[def_id] <- stab)
|
record!(self.tables.lookup_const_stability[def_id] <- stab)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1381,7 +1381,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||||
fn encode_deprecation(&mut self, def_id: DefId) {
|
fn encode_deprecation(&mut self, def_id: DefId) {
|
||||||
debug!("EncodeContext::encode_deprecation({:?})", def_id);
|
debug!("EncodeContext::encode_deprecation({:?})", def_id);
|
||||||
if let Some(depr) = self.tcx.lookup_deprecation(def_id) {
|
if let Some(depr) = self.tcx.lookup_deprecation(def_id) {
|
||||||
record!(self.tables.deprecation[def_id] <- depr);
|
record!(self.tables.lookup_deprecation_entry[def_id] <- depr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1670,12 +1670,12 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||||
self.tables.proc_macro_quoted_spans.set(i, span);
|
self.tables.proc_macro_quoted_spans.set(i, span);
|
||||||
}
|
}
|
||||||
|
|
||||||
record!(self.tables.def_kind[LOCAL_CRATE.as_def_id()] <- DefKind::Mod);
|
record!(self.tables.opt_def_kind[LOCAL_CRATE.as_def_id()] <- DefKind::Mod);
|
||||||
record!(self.tables.span[LOCAL_CRATE.as_def_id()] <- tcx.def_span(LOCAL_CRATE.as_def_id()));
|
record!(self.tables.def_span[LOCAL_CRATE.as_def_id()] <- tcx.def_span(LOCAL_CRATE.as_def_id()));
|
||||||
record!(self.tables.attributes[LOCAL_CRATE.as_def_id()] <- tcx.get_attrs(LOCAL_CRATE.as_def_id()));
|
record!(self.tables.attributes[LOCAL_CRATE.as_def_id()] <- tcx.get_attrs(LOCAL_CRATE.as_def_id()));
|
||||||
record!(self.tables.visibility[LOCAL_CRATE.as_def_id()] <- tcx.visibility(LOCAL_CRATE.as_def_id()));
|
record!(self.tables.visibility[LOCAL_CRATE.as_def_id()] <- tcx.visibility(LOCAL_CRATE.as_def_id()));
|
||||||
if let Some(stability) = stability {
|
if let Some(stability) = stability {
|
||||||
record!(self.tables.stability[LOCAL_CRATE.as_def_id()] <- stability);
|
record!(self.tables.lookup_stability[LOCAL_CRATE.as_def_id()] <- stability);
|
||||||
}
|
}
|
||||||
self.encode_deprecation(LOCAL_CRATE.as_def_id());
|
self.encode_deprecation(LOCAL_CRATE.as_def_id());
|
||||||
|
|
||||||
|
@ -1711,15 +1711,15 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||||
def_key.disambiguated_data.data = DefPathData::MacroNs(name);
|
def_key.disambiguated_data.data = DefPathData::MacroNs(name);
|
||||||
|
|
||||||
let def_id = id.to_def_id();
|
let def_id = id.to_def_id();
|
||||||
record!(self.tables.def_kind[def_id] <- DefKind::Macro(macro_kind));
|
record!(self.tables.opt_def_kind[def_id] <- DefKind::Macro(macro_kind));
|
||||||
record!(self.tables.kind[def_id] <- EntryKind::ProcMacro(macro_kind));
|
record!(self.tables.kind[def_id] <- EntryKind::ProcMacro(macro_kind));
|
||||||
record!(self.tables.attributes[def_id] <- attrs);
|
record!(self.tables.attributes[def_id] <- attrs);
|
||||||
record!(self.tables.def_keys[def_id] <- def_key);
|
record!(self.tables.def_keys[def_id] <- def_key);
|
||||||
record!(self.tables.ident_span[def_id] <- span);
|
record!(self.tables.def_ident_span[def_id] <- span);
|
||||||
record!(self.tables.span[def_id] <- span);
|
record!(self.tables.def_span[def_id] <- span);
|
||||||
record!(self.tables.visibility[def_id] <- ty::Visibility::Public);
|
record!(self.tables.visibility[def_id] <- ty::Visibility::Public);
|
||||||
if let Some(stability) = stability {
|
if let Some(stability) = stability {
|
||||||
record!(self.tables.stability[def_id] <- stability);
|
record!(self.tables.lookup_stability[def_id] <- stability);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1972,7 +1972,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||||
let def_id = def_id.to_def_id();
|
let def_id = def_id.to_def_id();
|
||||||
self.encode_info_for_generic_param(def_id, EntryKind::ConstParam, true);
|
self.encode_info_for_generic_param(def_id, EntryKind::ConstParam, true);
|
||||||
if default.is_some() {
|
if default.is_some() {
|
||||||
record!(self.tables.const_defaults[def_id] <- self.tcx.const_param_default(def_id))
|
record!(self.tables.const_param_default[def_id] <- self.tcx.const_param_default(def_id))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1986,7 +1986,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn encode_ident_span(&mut self, def_id: DefId, ident: Ident) {
|
fn encode_ident_span(&mut self, def_id: DefId, ident: Ident) {
|
||||||
record!(self.tables.ident_span[def_id] <- ident.span);
|
record!(self.tables.def_ident_span[def_id] <- ident.span);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// In some cases, along with the item itself, we also
|
/// In some cases, along with the item itself, we also
|
||||||
|
|
|
@ -275,35 +275,37 @@ macro_rules! define_tables {
|
||||||
}
|
}
|
||||||
|
|
||||||
define_tables! {
|
define_tables! {
|
||||||
def_kind: Table<DefIndex, Lazy<DefKind>>,
|
|
||||||
kind: Table<DefIndex, Lazy<EntryKind>>,
|
kind: Table<DefIndex, Lazy<EntryKind>>,
|
||||||
visibility: Table<DefIndex, Lazy<ty::Visibility>>,
|
|
||||||
span: Table<DefIndex, Lazy<Span>>,
|
|
||||||
ident_span: Table<DefIndex, Lazy<Span>>,
|
|
||||||
attributes: Table<DefIndex, Lazy<[ast::Attribute]>>,
|
attributes: Table<DefIndex, Lazy<[ast::Attribute]>>,
|
||||||
children: Table<DefIndex, Lazy<[DefIndex]>>,
|
children: Table<DefIndex, Lazy<[DefIndex]>>,
|
||||||
stability: Table<DefIndex, Lazy<attr::Stability>>,
|
|
||||||
const_stability: Table<DefIndex, Lazy<attr::ConstStability>>,
|
opt_def_kind: Table<DefIndex, Lazy<DefKind>>,
|
||||||
deprecation: Table<DefIndex, Lazy<attr::Deprecation>>,
|
visibility: Table<DefIndex, Lazy<ty::Visibility>>,
|
||||||
ty: Table<DefIndex, Lazy!(Ty<'tcx>)>,
|
def_span: Table<DefIndex, Lazy<Span>>,
|
||||||
fn_sig: Table<DefIndex, Lazy!(ty::PolyFnSig<'tcx>)>,
|
def_ident_span: Table<DefIndex, Lazy<Span>>,
|
||||||
impl_trait_ref: Table<DefIndex, Lazy!(ty::TraitRef<'tcx>)>,
|
lookup_stability: Table<DefIndex, Lazy<attr::Stability>>,
|
||||||
trait_item_def_id: Table<DefIndex, Lazy<DefId>>,
|
lookup_const_stability: Table<DefIndex, Lazy<attr::ConstStability>>,
|
||||||
inherent_impls: Table<DefIndex, Lazy<[DefIndex]>>,
|
lookup_deprecation_entry: Table<DefIndex, Lazy<attr::Deprecation>>,
|
||||||
variances: Table<DefIndex, Lazy<[ty::Variance]>>,
|
|
||||||
generics: Table<DefIndex, Lazy<ty::Generics>>,
|
|
||||||
explicit_predicates: Table<DefIndex, Lazy!(ty::GenericPredicates<'tcx>)>,
|
|
||||||
expn_that_defined: Table<DefIndex, Lazy<ExpnId>>,
|
|
||||||
// As an optimization, a missing entry indicates an empty `&[]`.
|
|
||||||
inferred_outlives: Table<DefIndex, Lazy!([(ty::Predicate<'tcx>, Span)])>,
|
|
||||||
super_predicates: Table<DefIndex, Lazy!(ty::GenericPredicates<'tcx>)>,
|
|
||||||
// As an optimization, a missing entry indicates an empty `&[]`.
|
// As an optimization, a missing entry indicates an empty `&[]`.
|
||||||
explicit_item_bounds: Table<DefIndex, Lazy!([(ty::Predicate<'tcx>, Span)])>,
|
explicit_item_bounds: Table<DefIndex, Lazy!([(ty::Predicate<'tcx>, Span)])>,
|
||||||
mir: Table<DefIndex, Lazy!(mir::Body<'tcx>)>,
|
explicit_predicates_of: Table<DefIndex, Lazy!(ty::GenericPredicates<'tcx>)>,
|
||||||
|
generics_of: Table<DefIndex, Lazy<ty::Generics>>,
|
||||||
|
// As an optimization, a missing entry indicates an empty `&[]`.
|
||||||
|
inferred_outlives_of: Table<DefIndex, Lazy!([(ty::Predicate<'tcx>, Span)])>,
|
||||||
|
super_predicates_of: Table<DefIndex, Lazy!(ty::GenericPredicates<'tcx>)>,
|
||||||
|
type_of: Table<DefIndex, Lazy!(Ty<'tcx>)>,
|
||||||
|
variances_of: Table<DefIndex, Lazy<[ty::Variance]>>,
|
||||||
|
fn_sig: Table<DefIndex, Lazy!(ty::PolyFnSig<'tcx>)>,
|
||||||
|
impl_trait_ref: Table<DefIndex, Lazy!(ty::TraitRef<'tcx>)>,
|
||||||
|
const_param_default: Table<DefIndex, Lazy<rustc_middle::ty::Const<'tcx>>>,
|
||||||
|
optimized_mir: Table<DefIndex, Lazy!(mir::Body<'tcx>)>,
|
||||||
mir_for_ctfe: Table<DefIndex, Lazy!(mir::Body<'tcx>)>,
|
mir_for_ctfe: Table<DefIndex, Lazy!(mir::Body<'tcx>)>,
|
||||||
promoted_mir: Table<DefIndex, Lazy!(IndexVec<mir::Promoted, mir::Body<'tcx>>)>,
|
promoted_mir: Table<DefIndex, Lazy!(IndexVec<mir::Promoted, mir::Body<'tcx>>)>,
|
||||||
thir_abstract_consts: Table<DefIndex, Lazy!(&'tcx [thir::abstract_const::Node<'tcx>])>,
|
thir_abstract_const: Table<DefIndex, Lazy!(&'tcx [thir::abstract_const::Node<'tcx>])>,
|
||||||
const_defaults: Table<DefIndex, Lazy<rustc_middle::ty::Const<'tcx>>>,
|
|
||||||
|
trait_item_def_id: Table<DefIndex, Lazy<DefId>>,
|
||||||
|
inherent_impls: Table<DefIndex, Lazy<[DefIndex]>>,
|
||||||
|
expn_that_defined: Table<DefIndex, Lazy<ExpnId>>,
|
||||||
unused_generic_params: Table<DefIndex, Lazy<FiniteBitSet<u32>>>,
|
unused_generic_params: Table<DefIndex, Lazy<FiniteBitSet<u32>>>,
|
||||||
// `def_keys` and `def_path_hashes` represent a lazy version of a
|
// `def_keys` and `def_path_hashes` represent a lazy version of a
|
||||||
// `DefPathTable`. This allows us to avoid deserializing an entire
|
// `DefPathTable`. This allows us to avoid deserializing an entire
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue