Use the query system to allocate.
This commit is contained in:
parent
bd42ef6e4f
commit
e56c400432
@ -347,15 +347,12 @@ pub fn provide(providers: &mut Providers<'_>) {
|
||||
if tcx.sess.opts.actually_rustdoc {
|
||||
// rustdoc needs to be able to document functions that use all the features, so
|
||||
// whitelist them all
|
||||
tcx.arena
|
||||
.alloc(llvm_util::all_known_features().map(|(a, b)| (a.to_string(), b)).collect())
|
||||
llvm_util::all_known_features().map(|(a, b)| (a.to_string(), b)).collect()
|
||||
} else {
|
||||
tcx.arena.alloc(
|
||||
llvm_util::target_feature_whitelist(tcx.sess)
|
||||
.iter()
|
||||
.map(|&(a, b)| (a.to_string(), b))
|
||||
.collect(),
|
||||
)
|
||||
llvm_util::target_feature_whitelist(tcx.sess)
|
||||
.iter()
|
||||
.map(|&(a, b)| (a.to_string(), b))
|
||||
.collect()
|
||||
}
|
||||
};
|
||||
|
||||
@ -387,7 +384,7 @@ pub fn provide_extern(providers: &mut Providers<'_>) {
|
||||
}));
|
||||
}
|
||||
|
||||
tcx.arena.alloc(ret)
|
||||
ret
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -42,14 +42,11 @@ pub fn crates_export_threshold(crate_types: &[config::CrateType]) -> SymbolExpor
|
||||
}
|
||||
}
|
||||
|
||||
fn reachable_non_generics_provider(
|
||||
tcx: TyCtxt<'_>,
|
||||
cnum: CrateNum,
|
||||
) -> &DefIdMap<SymbolExportLevel> {
|
||||
fn reachable_non_generics_provider(tcx: TyCtxt<'_>, cnum: CrateNum) -> DefIdMap<SymbolExportLevel> {
|
||||
assert_eq!(cnum, LOCAL_CRATE);
|
||||
|
||||
if !tcx.sess.opts.output_types.should_codegen() {
|
||||
return tcx.arena.alloc(Default::default());
|
||||
return Default::default();
|
||||
}
|
||||
|
||||
// Check to see if this crate is a "special runtime crate". These
|
||||
@ -145,7 +142,7 @@ fn reachable_non_generics_provider(
|
||||
reachable_non_generics.insert(id, SymbolExportLevel::C);
|
||||
}
|
||||
|
||||
tcx.arena.alloc(reachable_non_generics)
|
||||
reachable_non_generics
|
||||
}
|
||||
|
||||
fn is_reachable_non_generic_provider_local(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
|
||||
@ -281,7 +278,7 @@ fn exported_symbols_provider_local(
|
||||
fn upstream_monomorphizations_provider(
|
||||
tcx: TyCtxt<'_>,
|
||||
cnum: CrateNum,
|
||||
) -> &DefIdMap<FxHashMap<SubstsRef<'_>, CrateNum>> {
|
||||
) -> DefIdMap<FxHashMap<SubstsRef<'_>, CrateNum>> {
|
||||
debug_assert!(cnum == LOCAL_CRATE);
|
||||
|
||||
let cnums = tcx.all_crate_nums(LOCAL_CRATE);
|
||||
@ -338,7 +335,7 @@ fn upstream_monomorphizations_provider(
|
||||
}
|
||||
}
|
||||
|
||||
tcx.arena.alloc(instances)
|
||||
instances
|
||||
}
|
||||
|
||||
fn upstream_monomorphizations_for_provider(
|
||||
|
@ -908,7 +908,7 @@ pub fn provide_both(providers: &mut Providers<'_>) {
|
||||
.map(|id| &module_map[&id])
|
||||
.flat_map(|module| module.foreign_items.iter().cloned())
|
||||
.collect();
|
||||
tcx.arena.alloc(dllimports)
|
||||
dllimports
|
||||
};
|
||||
|
||||
providers.is_dllimport_foreign_item =
|
||||
|
@ -22,7 +22,7 @@ use rustc_span::symbol::{sym, Symbol};
|
||||
|
||||
use std::cmp;
|
||||
|
||||
fn lint_levels(tcx: TyCtxt<'_>, cnum: CrateNum) -> &LintLevelMap {
|
||||
fn lint_levels(tcx: TyCtxt<'_>, cnum: CrateNum) -> LintLevelMap {
|
||||
assert_eq!(cnum, LOCAL_CRATE);
|
||||
let store = unerased_lint_store(tcx);
|
||||
let levels = LintLevelsBuilder::new(tcx.sess, false, &store);
|
||||
@ -37,7 +37,7 @@ fn lint_levels(tcx: TyCtxt<'_>, cnum: CrateNum) -> &LintLevelMap {
|
||||
intravisit::walk_crate(&mut builder, krate);
|
||||
builder.levels.pop(push);
|
||||
|
||||
tcx.arena.alloc(builder.levels.build_map())
|
||||
builder.levels.build_map()
|
||||
}
|
||||
|
||||
pub struct LintLevelsBuilder<'s> {
|
||||
|
@ -798,7 +798,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
|
||||
)
|
||||
}
|
||||
|
||||
fn get_adt_def(&self, item_id: DefIndex, tcx: TyCtxt<'tcx>) -> &'tcx ty::AdtDef {
|
||||
fn get_adt_def(&self, item_id: DefIndex, tcx: TyCtxt<'tcx>) -> ty::AdtDef {
|
||||
let kind = self.kind(item_id);
|
||||
let did = self.local_def_id(item_id);
|
||||
|
||||
@ -939,8 +939,8 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
|
||||
}
|
||||
|
||||
/// Iterates over the diagnostic items in the given crate.
|
||||
fn get_diagnostic_items(&self, tcx: TyCtxt<'tcx>) -> &'tcx FxHashMap<Symbol, DefId> {
|
||||
tcx.arena.alloc(if self.root.is_proc_macro_crate() {
|
||||
fn get_diagnostic_items(&self) -> FxHashMap<Symbol, DefId> {
|
||||
if self.root.is_proc_macro_crate() {
|
||||
// Proc macro crates do not export any diagnostic-items to the target.
|
||||
Default::default()
|
||||
} else {
|
||||
@ -949,7 +949,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
|
||||
.decode(self)
|
||||
.map(|(name, def_index)| (name, self.local_def_id(def_index)))
|
||||
.collect()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// Iterates over each child of the given item.
|
||||
|
@ -88,15 +88,11 @@ impl IntoArgs for (CrateNum, DefId) {
|
||||
|
||||
provide! { <'tcx> tcx, def_id, other, cdata,
|
||||
type_of => { cdata.get_type(def_id.index, tcx) }
|
||||
generics_of => {
|
||||
tcx.arena.alloc(cdata.get_generics(def_id.index, tcx.sess))
|
||||
}
|
||||
generics_of => { cdata.get_generics(def_id.index, tcx.sess) }
|
||||
explicit_predicates_of => { cdata.get_explicit_predicates(def_id.index, tcx) }
|
||||
inferred_outlives_of => { cdata.get_inferred_outlives(def_id.index, tcx) }
|
||||
super_predicates_of => { cdata.get_super_predicates(def_id.index, tcx) }
|
||||
trait_def => {
|
||||
tcx.arena.alloc(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_destructor => {
|
||||
let _ = cdata;
|
||||
@ -117,8 +113,8 @@ provide! { <'tcx> tcx, def_id, other, cdata,
|
||||
bug!("coerce_unsized_info: `{:?}` is missing its info", def_id);
|
||||
})
|
||||
}
|
||||
optimized_mir => { tcx.arena.alloc(cdata.get_optimized_mir(tcx, def_id.index)) }
|
||||
promoted_mir => { tcx.arena.alloc(cdata.get_promoted_mir(tcx, def_id.index)) }
|
||||
optimized_mir => { cdata.get_optimized_mir(tcx, def_id.index) }
|
||||
promoted_mir => { cdata.get_promoted_mir(tcx, 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) }
|
||||
@ -178,7 +174,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
|
||||
})
|
||||
.collect();
|
||||
|
||||
tcx.arena.alloc(reachable_non_generics)
|
||||
reachable_non_generics
|
||||
}
|
||||
native_libraries => { Lrc::new(cdata.get_native_libraries(tcx.sess)) }
|
||||
foreign_modules => { cdata.get_foreign_modules(tcx) }
|
||||
@ -220,7 +216,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
|
||||
}
|
||||
defined_lib_features => { cdata.get_lib_features(tcx) }
|
||||
defined_lang_items => { cdata.get_lang_items(tcx) }
|
||||
diagnostic_items => { cdata.get_diagnostic_items(tcx) }
|
||||
diagnostic_items => { cdata.get_diagnostic_items() }
|
||||
missing_lang_items => { cdata.get_missing_lang_items(tcx) }
|
||||
|
||||
missing_extern_crate_item => {
|
||||
@ -363,7 +359,7 @@ pub fn provide(providers: &mut Providers<'_>) {
|
||||
}
|
||||
}
|
||||
|
||||
tcx.arena.alloc(visible_parent_map)
|
||||
visible_parent_map
|
||||
},
|
||||
|
||||
dependency_formats: |tcx, cnum| {
|
||||
|
@ -12,36 +12,10 @@ macro_rules! arena_types {
|
||||
($macro:path, $args:tt, $tcx:lifetime) => (
|
||||
$macro!($args, [
|
||||
[] layouts: rustc_target::abi::Layout,
|
||||
[] generics: rustc_middle::ty::Generics,
|
||||
[] trait_def: rustc_middle::ty::TraitDef,
|
||||
[] adt_def: rustc_middle::ty::AdtDef,
|
||||
[] steal_mir: rustc_middle::ty::steal::Steal<rustc_middle::mir::Body<$tcx>>,
|
||||
[] mir: rustc_middle::mir::Body<$tcx>,
|
||||
[] steal_promoted: rustc_middle::ty::steal::Steal<
|
||||
rustc_index::vec::IndexVec<
|
||||
rustc_middle::mir::Promoted,
|
||||
rustc_middle::mir::Body<$tcx>
|
||||
>
|
||||
>,
|
||||
[] promoted: rustc_index::vec::IndexVec<
|
||||
rustc_middle::mir::Promoted,
|
||||
rustc_middle::mir::Body<$tcx>
|
||||
>,
|
||||
[decode] tables: rustc_middle::ty::TypeckTables<$tcx>,
|
||||
[decode] borrowck_result: rustc_middle::mir::BorrowCheckResult<$tcx>,
|
||||
[] const_allocs: rustc_middle::mir::interpret::Allocation,
|
||||
[] vtable_method: Option<(
|
||||
rustc_hir::def_id::DefId,
|
||||
rustc_middle::ty::subst::SubstsRef<$tcx>
|
||||
)>,
|
||||
[few, decode] collect_and_partition_mono_items: rustc_hir::def_id::DefIdSet,
|
||||
[few, decode] mir_keys: rustc_data_structures::fx::FxHashSet<rustc_hir::def_id::LocalDefId>,
|
||||
[decode] specialization_graph: rustc_middle::traits::specialization_graph::Graph,
|
||||
[few, decode] mir_keys: rustc_hir::def_id::DefIdSet,
|
||||
[] region_scope_tree: rustc_middle::middle::region::ScopeTree,
|
||||
[] item_local_set: rustc_hir::ItemLocalSet,
|
||||
[decode] mir_const_qualif: rustc_index::bit_set::BitSet<rustc_middle::mir::Local>,
|
||||
[] trait_impls_of: rustc_middle::ty::trait_def::TraitImpls,
|
||||
[] associated_items: rustc_middle::ty::AssociatedItems,
|
||||
[] dropck_outlives:
|
||||
rustc_middle::infer::canonical::Canonical<'tcx,
|
||||
rustc_middle::infer::canonical::QueryResponse<'tcx,
|
||||
@ -80,42 +54,10 @@ macro_rules! arena_types {
|
||||
rustc_middle::infer::canonical::Canonical<'tcx,
|
||||
rustc_middle::infer::canonical::QueryResponse<'tcx, rustc_middle::ty::Ty<'tcx>>
|
||||
>,
|
||||
[few] crate_inherent_impls: rustc_middle::ty::CrateInherentImpls,
|
||||
[few] upstream_monomorphizations:
|
||||
rustc_hir::def_id::DefIdMap<
|
||||
rustc_data_structures::fx::FxHashMap<
|
||||
rustc_middle::ty::subst::SubstsRef<'tcx>,
|
||||
rustc_hir::def_id::CrateNum
|
||||
>
|
||||
>,
|
||||
[few] diagnostic_items: rustc_data_structures::fx::FxHashMap<
|
||||
rustc_span::symbol::Symbol,
|
||||
rustc_hir::def_id::DefId,
|
||||
>,
|
||||
[few] resolve_lifetimes: rustc_middle::middle::resolve_lifetime::ResolveLifetimes,
|
||||
[few] lint_levels: rustc_middle::lint::LintLevelMap,
|
||||
[few] stability_index: rustc_middle::middle::stability::Index<'tcx>,
|
||||
[few] features: rustc_feature::Features,
|
||||
[few] all_traits: Vec<rustc_hir::def_id::DefId>,
|
||||
[few] privacy_access_levels: rustc_middle::middle::privacy::AccessLevels,
|
||||
[few] target_features_whitelist: rustc_data_structures::fx::FxHashMap<
|
||||
String,
|
||||
Option<rustc_span::symbol::Symbol>
|
||||
>,
|
||||
[few] wasm_import_module_map: rustc_data_structures::fx::FxHashMap<
|
||||
rustc_hir::def_id::DefId,
|
||||
String
|
||||
>,
|
||||
[few] get_lib_features: rustc_middle::middle::lib_features::LibFeatures,
|
||||
[few] defined_lib_features: rustc_hir::lang_items::LanguageItems,
|
||||
[few] visible_parent_map: rustc_hir::def_id::DefIdMap<rustc_hir::def_id::DefId>,
|
||||
[few] foreign_module: rustc_middle::middle::cstore::ForeignModule,
|
||||
[few] foreign_modules: Vec<rustc_middle::middle::cstore::ForeignModule>,
|
||||
[few] reachable_non_generics: rustc_hir::def_id::DefIdMap<
|
||||
rustc_middle::middle::exported_symbols::SymbolExportLevel
|
||||
>,
|
||||
[few] crate_variances: rustc_middle::ty::CrateVariancesMap<'tcx>,
|
||||
[few] inferred_outlives_crate: rustc_middle::ty::CratePredicatesMap<'tcx>,
|
||||
[] upvars: rustc_data_structures::fx::FxIndexMap<rustc_hir::HirId, rustc_hir::Upvar>,
|
||||
[] object_safety_violations: rustc_middle::traits::ObjectSafetyViolation,
|
||||
[] codegen_unit: rustc_middle::mir::mono::CodegenUnit<$tcx>,
|
||||
|
@ -102,12 +102,13 @@ rustc_queries! {
|
||||
|
||||
/// Maps from the `DefId` of an item (trait/struct/enum/fn) to its
|
||||
/// associated generics.
|
||||
query generics_of(key: DefId) -> &'tcx ty::Generics {
|
||||
query generics_of(key: DefId) -> ty::Generics {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
cache_on_disk_if { key.is_local() }
|
||||
load_cached(tcx, id) {
|
||||
let generics: Option<ty::Generics> = tcx.queries.on_disk_cache
|
||||
.try_load_query_result(tcx, id);
|
||||
generics.map(|x| &*tcx.arena.alloc(x))
|
||||
generics
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,7 +135,8 @@ rustc_queries! {
|
||||
desc { "looking up the native libraries of a linked crate" }
|
||||
}
|
||||
|
||||
query lint_levels(_: CrateNum) -> &'tcx LintLevelMap {
|
||||
query lint_levels(_: CrateNum) -> LintLevelMap {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
eval_always
|
||||
desc { "computing the lint levels for items in this crate" }
|
||||
}
|
||||
@ -171,7 +173,8 @@ rustc_queries! {
|
||||
|
||||
/// Fetch the MIR for a given `DefId` right after it's built - this includes
|
||||
/// unreachable code.
|
||||
query mir_built(_: LocalDefId) -> &'tcx Steal<mir::Body<'tcx>> {
|
||||
query mir_built(_: LocalDefId) -> Steal<mir::Body<'tcx>> {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
desc { "building MIR for" }
|
||||
}
|
||||
|
||||
@ -179,40 +182,31 @@ rustc_queries! {
|
||||
/// ready for const evaluation.
|
||||
///
|
||||
/// See the README for the `mir` module for details.
|
||||
query mir_const(_: DefId) -> &'tcx Steal<mir::Body<'tcx>> {
|
||||
query mir_const(_: DefId) -> Steal<mir::Body<'tcx>> {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
no_hash
|
||||
}
|
||||
|
||||
query mir_validated(key: LocalDefId) ->
|
||||
(
|
||||
&'tcx Steal<mir::Body<'tcx>>,
|
||||
&'tcx Steal<IndexVec<mir::Promoted, mir::Body<'tcx>>>
|
||||
Steal<mir::Body<'tcx>>,
|
||||
Steal<IndexVec<mir::Promoted, mir::Body<'tcx>>>
|
||||
) {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
no_hash
|
||||
desc { |tcx| "processing `{}`", tcx.def_path_str(key.to_def_id()) }
|
||||
}
|
||||
|
||||
/// MIR after our optimization passes have run. This is MIR that is ready
|
||||
/// for codegen. This is also the only query that can fetch non-local MIR, at present.
|
||||
query optimized_mir(key: DefId) -> &'tcx mir::Body<'tcx> {
|
||||
query optimized_mir(key: DefId) -> mir::Body<'tcx> {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
cache_on_disk_if { key.is_local() }
|
||||
load_cached(tcx, id) {
|
||||
let mir: Option<crate::mir::Body<'tcx>>
|
||||
= tcx.queries.on_disk_cache.try_load_query_result(tcx, id);
|
||||
mir.map(|x| &*tcx.arena.alloc(x))
|
||||
}
|
||||
}
|
||||
|
||||
query promoted_mir(key: DefId) -> &'tcx IndexVec<mir::Promoted, mir::Body<'tcx>> {
|
||||
query promoted_mir(key: DefId) -> IndexVec<mir::Promoted, mir::Body<'tcx>> {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
cache_on_disk_if { key.is_local() }
|
||||
load_cached(tcx, id) {
|
||||
let promoted: Option<
|
||||
rustc_index::vec::IndexVec<
|
||||
crate::mir::Promoted,
|
||||
crate::mir::Body<'tcx>
|
||||
>> = tcx.queries.on_disk_cache.try_load_query_result(tcx, id);
|
||||
promoted.map(|p| &*tcx.arena.alloc(p))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -246,7 +240,8 @@ rustc_queries! {
|
||||
}
|
||||
|
||||
Linking {
|
||||
query wasm_import_module_map(_: CrateNum) -> &'tcx FxHashMap<DefId, String> {
|
||||
query wasm_import_module_map(_: CrateNum) -> FxHashMap<DefId, String> {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
desc { "wasm import module map" }
|
||||
}
|
||||
}
|
||||
@ -284,8 +279,12 @@ rustc_queries! {
|
||||
}}
|
||||
}
|
||||
|
||||
query trait_def(_: DefId) -> &'tcx ty::TraitDef {}
|
||||
query adt_def(_: DefId) -> &'tcx ty::AdtDef {}
|
||||
query trait_def(_: DefId) -> ty::TraitDef {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
}
|
||||
query adt_def(_: DefId) -> ty::AdtDef {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
}
|
||||
query adt_destructor(_: DefId) -> Option<ty::Destructor> {}
|
||||
|
||||
// The cycle error here should be reported as an error by `check_representable`.
|
||||
@ -346,7 +345,8 @@ rustc_queries! {
|
||||
query generator_kind(_: DefId) -> Option<hir::GeneratorKind> {}
|
||||
|
||||
/// Gets a map with the variance of every item; use `item_variance` instead.
|
||||
query crate_variances(_: CrateNum) -> &'tcx ty::CrateVariancesMap<'tcx> {
|
||||
query crate_variances(_: CrateNum) -> ty::CrateVariancesMap<'tcx> {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
desc { "computing the variances for items in this crate" }
|
||||
}
|
||||
|
||||
@ -357,7 +357,8 @@ rustc_queries! {
|
||||
TypeChecking {
|
||||
/// Maps from thee `DefId` of a type to its (inferred) outlives.
|
||||
query inferred_outlives_crate(_: CrateNum)
|
||||
-> &'tcx ty::CratePredicatesMap<'tcx> {
|
||||
-> ty::CratePredicatesMap<'tcx> {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
desc { "computing the inferred outlives predicates for items in this crate" }
|
||||
}
|
||||
}
|
||||
@ -370,7 +371,8 @@ rustc_queries! {
|
||||
query associated_item(_: DefId) -> ty::AssocItem {}
|
||||
|
||||
/// Collects the associated items defined on a trait or impl.
|
||||
query associated_items(key: DefId) -> &'tcx ty::AssociatedItems {
|
||||
query associated_items(key: DefId) -> ty::AssociatedItems {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
desc { |tcx| "collecting associated items of {}", tcx.def_path_str(key) }
|
||||
}
|
||||
|
||||
@ -473,7 +475,7 @@ rustc_queries! {
|
||||
.queries.on_disk_cache
|
||||
.try_load_query_result(tcx, id);
|
||||
|
||||
typeck_tables.map(|tables| &*tcx.arena.alloc(tables))
|
||||
typeck_tables.map(|x| &*tcx.arena.alloc(x))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -496,7 +498,8 @@ rustc_queries! {
|
||||
BorrowChecking {
|
||||
/// Borrow-checks the function body. If this is a closure, returns
|
||||
/// additional requirements that the closure's creator must verify.
|
||||
query mir_borrowck(key: LocalDefId) -> &'tcx mir::BorrowCheckResult<'tcx> {
|
||||
query mir_borrowck(key: LocalDefId) -> mir::BorrowCheckResult<'tcx> {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
desc { |tcx| "borrow-checking `{}`", tcx.def_path_str(key.to_def_id()) }
|
||||
cache_on_disk_if(tcx, opt_result) {
|
||||
tcx.is_closure(key.to_def_id())
|
||||
@ -510,7 +513,8 @@ rustc_queries! {
|
||||
/// Not meant to be used directly outside of coherence.
|
||||
/// (Defined only for `LOCAL_CRATE`.)
|
||||
query crate_inherent_impls(k: CrateNum)
|
||||
-> &'tcx CrateInherentImpls {
|
||||
-> CrateInherentImpls {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
eval_always
|
||||
desc { "all inherent impls defined in crate `{:?}`", k }
|
||||
}
|
||||
@ -611,7 +615,8 @@ rustc_queries! {
|
||||
/// in the case of closures, this will be redirected to the enclosing function.
|
||||
query region_scope_tree(_: DefId) -> &'tcx region::ScopeTree {}
|
||||
|
||||
query mir_shims(key: ty::InstanceDef<'tcx>) -> &'tcx mir::Body<'tcx> {
|
||||
query mir_shims(key: ty::InstanceDef<'tcx>) -> mir::Body<'tcx> {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
desc { |tcx| "generating MIR shim for `{}`", tcx.def_path_str(key.def_id()) }
|
||||
}
|
||||
|
||||
@ -685,10 +690,12 @@ rustc_queries! {
|
||||
query all_local_trait_impls(key: CrateNum) -> &'tcx BTreeMap<DefId, Vec<hir::HirId>> {
|
||||
desc { "local trait impls" }
|
||||
}
|
||||
query trait_impls_of(key: DefId) -> &'tcx ty::trait_def::TraitImpls {
|
||||
query trait_impls_of(key: DefId) -> ty::trait_def::TraitImpls {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
desc { |tcx| "trait impls of `{}`", tcx.def_path_str(key) }
|
||||
}
|
||||
query specialization_graph_of(key: DefId) -> &'tcx specialization_graph::Graph {
|
||||
query specialization_graph_of(key: DefId) -> specialization_graph::Graph {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
desc { |tcx| "building specialization graph of trait `{}`", tcx.def_path_str(key) }
|
||||
cache_on_disk_if { true }
|
||||
}
|
||||
@ -830,7 +837,8 @@ rustc_queries! {
|
||||
// Does not include external symbols that don't have a corresponding DefId,
|
||||
// like the compiler-generated `main` function and so on.
|
||||
query reachable_non_generics(_: CrateNum)
|
||||
-> &'tcx DefIdMap<SymbolExportLevel> {
|
||||
-> DefIdMap<SymbolExportLevel> {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
desc { "looking up the exported symbols of a crate" }
|
||||
}
|
||||
query is_reachable_non_generic(_: DefId) -> bool {}
|
||||
@ -846,7 +854,8 @@ rustc_queries! {
|
||||
/// better, `Instance::upstream_monomorphization()`.
|
||||
query upstream_monomorphizations(
|
||||
k: CrateNum
|
||||
) -> &'tcx DefIdMap<FxHashMap<SubstsRef<'tcx>, CrateNum>> {
|
||||
) -> DefIdMap<FxHashMap<SubstsRef<'tcx>, CrateNum>> {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
desc { "collecting available upstream monomorphizations `{:?}`", k }
|
||||
}
|
||||
|
||||
@ -931,7 +940,8 @@ rustc_queries! {
|
||||
|
||||
Other {
|
||||
query dllimport_foreign_items(_: CrateNum)
|
||||
-> &'tcx FxHashSet<DefId> {
|
||||
-> FxHashSet<DefId> {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
desc { "dllimport_foreign_items" }
|
||||
}
|
||||
query is_dllimport_foreign_item(_: DefId) -> bool {}
|
||||
@ -949,7 +959,8 @@ rustc_queries! {
|
||||
|
||||
BorrowChecking {
|
||||
/// Lifetime resolution. See `middle::resolve_lifetimes`.
|
||||
query resolve_lifetimes(_: CrateNum) -> &'tcx ResolveLifetimes {
|
||||
query resolve_lifetimes(_: CrateNum) -> ResolveLifetimes {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
desc { "resolving lifetimes" }
|
||||
}
|
||||
query named_region_map(_: LocalDefId) ->
|
||||
@ -982,7 +993,8 @@ rustc_queries! {
|
||||
query item_children(_: DefId) -> &'tcx [Export<hir::HirId>] {}
|
||||
query extern_mod_stmt_cnum(_: DefId) -> Option<CrateNum> {}
|
||||
|
||||
query get_lib_features(_: CrateNum) -> &'tcx LibFeatures {
|
||||
query get_lib_features(_: CrateNum) -> LibFeatures {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
eval_always
|
||||
desc { "calculating the lib features map" }
|
||||
}
|
||||
@ -993,13 +1005,15 @@ rustc_queries! {
|
||||
/// Returns the lang items defined in another crate by loading it from metadata.
|
||||
// FIXME: It is illegal to pass a `CrateNum` other than `LOCAL_CRATE` here, just get rid
|
||||
// of that argument?
|
||||
query get_lang_items(_: CrateNum) -> &'tcx LanguageItems {
|
||||
query get_lang_items(_: CrateNum) -> LanguageItems {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
eval_always
|
||||
desc { "calculating the lang items map" }
|
||||
}
|
||||
|
||||
/// Returns all diagnostic items defined in all crates.
|
||||
query all_diagnostic_items(_: CrateNum) -> &'tcx FxHashMap<Symbol, DefId> {
|
||||
query all_diagnostic_items(_: CrateNum) -> FxHashMap<Symbol, DefId> {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
eval_always
|
||||
desc { "calculating the diagnostic items map" }
|
||||
}
|
||||
@ -1010,7 +1024,8 @@ rustc_queries! {
|
||||
}
|
||||
|
||||
/// Returns the diagnostic items defined in a crate.
|
||||
query diagnostic_items(_: CrateNum) -> &'tcx FxHashMap<Symbol, DefId> {
|
||||
query diagnostic_items(_: CrateNum) -> FxHashMap<Symbol, DefId> {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
desc { "calculating the diagnostic items map in a crate" }
|
||||
}
|
||||
|
||||
@ -1018,7 +1033,8 @@ rustc_queries! {
|
||||
desc { "calculating the missing lang items in a crate" }
|
||||
}
|
||||
query visible_parent_map(_: CrateNum)
|
||||
-> &'tcx DefIdMap<DefId> {
|
||||
-> DefIdMap<DefId> {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
desc { "calculating the visible parent map" }
|
||||
}
|
||||
query missing_extern_crate_item(_: CrateNum) -> bool {
|
||||
@ -1052,7 +1068,8 @@ rustc_queries! {
|
||||
desc { |tcx| "names_imported_by_glob_use for `{}`", tcx.def_path_str(def_id.to_def_id()) }
|
||||
}
|
||||
|
||||
query stability_index(_: CrateNum) -> &'tcx stability::Index<'tcx> {
|
||||
query stability_index(_: CrateNum) -> stability::Index<'tcx> {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
eval_always
|
||||
desc { "calculating the stability index for the local crate" }
|
||||
}
|
||||
@ -1243,7 +1260,8 @@ rustc_queries! {
|
||||
}
|
||||
|
||||
Other {
|
||||
query target_features_whitelist(_: CrateNum) -> &'tcx FxHashMap<String, Option<Symbol>> {
|
||||
query target_features_whitelist(_: CrateNum) -> FxHashMap<String, Option<Symbol>> {
|
||||
storage(ArenaCacheSelector<'tcx>)
|
||||
eval_always
|
||||
desc { "looking up the whitelist of target features" }
|
||||
}
|
||||
|
@ -991,22 +991,15 @@ pub struct GlobalCtxt<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> TyCtxt<'tcx> {
|
||||
pub fn alloc_steal_mir(self, mir: Body<'tcx>) -> &'tcx Steal<Body<'tcx>> {
|
||||
self.arena.alloc(Steal::new(mir))
|
||||
pub fn alloc_steal_mir(self, mir: Body<'tcx>) -> Steal<Body<'tcx>> {
|
||||
Steal::new(mir)
|
||||
}
|
||||
|
||||
pub fn alloc_steal_promoted(
|
||||
self,
|
||||
promoted: IndexVec<Promoted, Body<'tcx>>,
|
||||
) -> &'tcx Steal<IndexVec<Promoted, Body<'tcx>>> {
|
||||
self.arena.alloc(Steal::new(promoted))
|
||||
}
|
||||
|
||||
pub fn intern_promoted(
|
||||
self,
|
||||
promoted: IndexVec<Promoted, Body<'tcx>>,
|
||||
) -> &'tcx IndexVec<Promoted, Body<'tcx>> {
|
||||
self.arena.alloc(promoted)
|
||||
) -> Steal<IndexVec<Promoted, Body<'tcx>>> {
|
||||
Steal::new(promoted)
|
||||
}
|
||||
|
||||
pub fn alloc_adt_def(
|
||||
@ -1015,9 +1008,8 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
kind: AdtKind,
|
||||
variants: IndexVec<VariantIdx, ty::VariantDef>,
|
||||
repr: ReprOptions,
|
||||
) -> &'tcx ty::AdtDef {
|
||||
let def = ty::AdtDef::new(self, did, kind, variants, repr);
|
||||
self.arena.alloc(def)
|
||||
) -> ty::AdtDef {
|
||||
ty::AdtDef::new(self, did, kind, variants, repr)
|
||||
}
|
||||
|
||||
pub fn intern_const_alloc(self, alloc: Allocation) -> &'tcx Allocation {
|
||||
@ -2745,7 +2737,7 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) {
|
||||
};
|
||||
providers.features_query = |tcx, cnum| {
|
||||
assert_eq!(cnum, LOCAL_CRATE);
|
||||
tcx.arena.alloc(tcx.sess.features_untracked().clone())
|
||||
tcx.sess.features_untracked()
|
||||
};
|
||||
providers.is_panic_runtime = |tcx, cnum| {
|
||||
assert_eq!(cnum, LOCAL_CRATE);
|
||||
|
@ -187,7 +187,7 @@ pub(super) fn all_local_trait_impls<'tcx>(
|
||||
}
|
||||
|
||||
// Query provider for `trait_impls_of`.
|
||||
pub(super) fn trait_impls_of_provider(tcx: TyCtxt<'_>, trait_id: DefId) -> &TraitImpls {
|
||||
pub(super) fn trait_impls_of_provider(tcx: TyCtxt<'_>, trait_id: DefId) -> TraitImpls {
|
||||
let mut impls = TraitImpls::default();
|
||||
|
||||
{
|
||||
@ -219,7 +219,7 @@ pub(super) fn trait_impls_of_provider(tcx: TyCtxt<'_>, trait_id: DefId) -> &Trai
|
||||
}
|
||||
}
|
||||
|
||||
tcx.arena.alloc(impls)
|
||||
impls
|
||||
}
|
||||
|
||||
impl<'a> HashStable<StableHashingContext<'a>> for TraitImpls {
|
||||
|
@ -92,7 +92,7 @@ pub fn provide(providers: &mut Providers<'_>) {
|
||||
*providers = Providers { mir_borrowck, ..*providers };
|
||||
}
|
||||
|
||||
fn mir_borrowck(tcx: TyCtxt<'_>, def_id: LocalDefId) -> &BorrowCheckResult<'_> {
|
||||
fn mir_borrowck(tcx: TyCtxt<'_>, def_id: LocalDefId) -> BorrowCheckResult<'_> {
|
||||
let (input_body, promoted) = tcx.mir_validated(def_id);
|
||||
debug!("run query mir_borrowck: {}", tcx.def_path_str(def_id.to_def_id()));
|
||||
|
||||
@ -103,7 +103,7 @@ fn mir_borrowck(tcx: TyCtxt<'_>, def_id: LocalDefId) -> &BorrowCheckResult<'_> {
|
||||
});
|
||||
debug!("mir_borrowck done");
|
||||
|
||||
tcx.arena.alloc(opt_closure_req)
|
||||
opt_closure_req
|
||||
}
|
||||
|
||||
fn do_mir_borrowck<'a, 'tcx>(
|
||||
|
@ -26,7 +26,7 @@ pub fn provide(providers: &mut Providers<'_>) {
|
||||
providers.mir_shims = make_shim;
|
||||
}
|
||||
|
||||
fn make_shim<'tcx>(tcx: TyCtxt<'tcx>, instance: ty::InstanceDef<'tcx>) -> &'tcx Body<'tcx> {
|
||||
fn make_shim<'tcx>(tcx: TyCtxt<'tcx>, instance: ty::InstanceDef<'tcx>) -> Body<'tcx> {
|
||||
debug!("make_shim({:?})", instance);
|
||||
|
||||
let mut result = match instance {
|
||||
@ -128,7 +128,7 @@ fn make_shim<'tcx>(tcx: TyCtxt<'tcx>, instance: ty::InstanceDef<'tcx>) -> &'tcx
|
||||
|
||||
debug!("make_shim({:?}) = {:?}", instance, result);
|
||||
|
||||
tcx.arena.alloc(result)
|
||||
result
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
@ -828,7 +828,7 @@ fn build_call_shim<'tcx>(
|
||||
body
|
||||
}
|
||||
|
||||
pub fn build_adt_ctor(tcx: TyCtxt<'_>, ctor_id: DefId) -> &Body<'_> {
|
||||
pub fn build_adt_ctor(tcx: TyCtxt<'_>, ctor_id: DefId) -> Body<'_> {
|
||||
debug_assert!(tcx.is_constructor(ctor_id));
|
||||
|
||||
let span =
|
||||
@ -895,5 +895,5 @@ pub fn build_adt_ctor(tcx: TyCtxt<'_>, ctor_id: DefId) -> &Body<'_> {
|
||||
|_, _| Ok(()),
|
||||
);
|
||||
|
||||
tcx.arena.alloc(body)
|
||||
body
|
||||
}
|
||||
|
@ -211,7 +211,7 @@ fn mir_const_qualif(tcx: TyCtxt<'_>, def_id: DefId) -> ConstQualifs {
|
||||
validator.qualifs_in_return_place()
|
||||
}
|
||||
|
||||
fn mir_const(tcx: TyCtxt<'_>, def_id: DefId) -> &Steal<Body<'_>> {
|
||||
fn mir_const(tcx: TyCtxt<'_>, def_id: DefId) -> Steal<Body<'_>> {
|
||||
let def_id = def_id.expect_local();
|
||||
|
||||
// Unsafety check uses the raw mir, so make sure it is run
|
||||
@ -241,7 +241,7 @@ fn mir_const(tcx: TyCtxt<'_>, def_id: DefId) -> &Steal<Body<'_>> {
|
||||
fn mir_validated(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
def_id: LocalDefId,
|
||||
) -> (&'tcx Steal<Body<'tcx>>, &'tcx Steal<IndexVec<Promoted, Body<'tcx>>>) {
|
||||
) -> (Steal<Body<'tcx>>, Steal<IndexVec<Promoted, Body<'tcx>>>) {
|
||||
// Ensure that we compute the `mir_const_qualif` for constants at
|
||||
// this point, before we steal the mir-const result.
|
||||
let _ = tcx.mir_const_qualif(def_id.to_def_id());
|
||||
@ -360,7 +360,7 @@ fn run_optimization_passes<'tcx>(
|
||||
);
|
||||
}
|
||||
|
||||
fn optimized_mir(tcx: TyCtxt<'_>, def_id: DefId) -> &Body<'_> {
|
||||
fn optimized_mir(tcx: TyCtxt<'_>, def_id: DefId) -> Body<'_> {
|
||||
if tcx.is_constructor(def_id) {
|
||||
// There's no reason to run all of the MIR passes on constructors when
|
||||
// we can just output the MIR we want directly. This also saves const
|
||||
@ -381,12 +381,12 @@ fn optimized_mir(tcx: TyCtxt<'_>, def_id: DefId) -> &Body<'_> {
|
||||
|
||||
debug_assert!(!body.has_free_regions(), "Free regions in optimized MIR");
|
||||
|
||||
tcx.arena.alloc(body)
|
||||
body
|
||||
}
|
||||
|
||||
fn promoted_mir(tcx: TyCtxt<'_>, def_id: DefId) -> &IndexVec<Promoted, Body<'_>> {
|
||||
fn promoted_mir(tcx: TyCtxt<'_>, def_id: DefId) -> IndexVec<Promoted, Body<'_>> {
|
||||
if tcx.is_constructor(def_id) {
|
||||
return tcx.intern_promoted(IndexVec::new());
|
||||
return IndexVec::new();
|
||||
}
|
||||
|
||||
let def_id = def_id.expect_local();
|
||||
@ -401,5 +401,5 @@ fn promoted_mir(tcx: TyCtxt<'_>, def_id: DefId) -> &IndexVec<Promoted, Body<'_>>
|
||||
|
||||
debug_assert!(!promoted.has_free_regions(), "Free regions in promoted MIR");
|
||||
|
||||
tcx.intern_promoted(promoted)
|
||||
promoted
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ use rustc_target::spec::PanicStrategy;
|
||||
|
||||
use super::lints;
|
||||
|
||||
crate fn mir_built(tcx: TyCtxt<'_>, def_id: LocalDefId) -> &ty::steal::Steal<Body<'_>> {
|
||||
crate fn mir_built(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::steal::Steal<Body<'_>> {
|
||||
tcx.alloc_steal_mir(mir_build(tcx, def_id))
|
||||
}
|
||||
|
||||
|
@ -93,18 +93,18 @@ fn extract(attrs: &[ast::Attribute]) -> Option<Symbol> {
|
||||
}
|
||||
|
||||
/// Traverse and collect the diagnostic items in the current
|
||||
fn collect<'tcx>(tcx: TyCtxt<'tcx>) -> &'tcx FxHashMap<Symbol, DefId> {
|
||||
fn collect<'tcx>(tcx: TyCtxt<'tcx>) -> FxHashMap<Symbol, DefId> {
|
||||
// Initialize the collector.
|
||||
let mut collector = DiagnosticItemCollector::new(tcx);
|
||||
|
||||
// Collect diagnostic items in this crate.
|
||||
tcx.hir().krate().visit_all_item_likes(&mut collector);
|
||||
|
||||
tcx.arena.alloc(collector.items)
|
||||
collector.items
|
||||
}
|
||||
|
||||
/// Traverse and collect all the diagnostic items in all crates.
|
||||
fn collect_all<'tcx>(tcx: TyCtxt<'tcx>) -> &'tcx FxHashMap<Symbol, DefId> {
|
||||
fn collect_all<'tcx>(tcx: TyCtxt<'tcx>) -> FxHashMap<Symbol, DefId> {
|
||||
// Initialize the collector.
|
||||
let mut collector = FxHashMap::default();
|
||||
|
||||
@ -115,7 +115,7 @@ fn collect_all<'tcx>(tcx: TyCtxt<'tcx>) -> &'tcx FxHashMap<Symbol, DefId> {
|
||||
}
|
||||
}
|
||||
|
||||
tcx.arena.alloc(collector)
|
||||
collector
|
||||
}
|
||||
|
||||
pub fn provide(providers: &mut Providers<'_>) {
|
||||
|
@ -169,6 +169,6 @@ fn collect(tcx: TyCtxt<'_>) -> LanguageItems {
|
||||
pub fn provide(providers: &mut Providers<'_>) {
|
||||
providers.get_lang_items = |tcx, id| {
|
||||
assert_eq!(id, LOCAL_CRATE);
|
||||
tcx.arena.alloc(collect(tcx))
|
||||
collect(tcx)
|
||||
};
|
||||
}
|
||||
|
@ -138,6 +138,6 @@ fn collect(tcx: TyCtxt<'_>) -> LibFeatures {
|
||||
pub fn provide(providers: &mut Providers<'_>) {
|
||||
providers.get_lib_features = |tcx, id| {
|
||||
assert_eq!(id, LOCAL_CRATE);
|
||||
tcx.arena.alloc(collect(tcx))
|
||||
collect(tcx)
|
||||
};
|
||||
}
|
||||
|
@ -480,7 +480,7 @@ pub(crate) fn provide(providers: &mut Providers<'_>) {
|
||||
*providers = Providers { check_mod_unstable_api_usage, ..*providers };
|
||||
providers.stability_index = |tcx, cnum| {
|
||||
assert_eq!(cnum, LOCAL_CRATE);
|
||||
tcx.arena.alloc(new_index(tcx))
|
||||
new_index(tcx)
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -294,7 +294,7 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) {
|
||||
/// entire crate. You should not read the result of this query
|
||||
/// directly, but rather use `named_region_map`, `is_late_bound_map`,
|
||||
/// etc.
|
||||
fn resolve_lifetimes(tcx: TyCtxt<'_>, for_krate: CrateNum) -> &ResolveLifetimes {
|
||||
fn resolve_lifetimes(tcx: TyCtxt<'_>, for_krate: CrateNum) -> ResolveLifetimes {
|
||||
assert_eq!(for_krate, LOCAL_CRATE);
|
||||
|
||||
let named_region_map = krate(tcx);
|
||||
@ -314,7 +314,7 @@ fn resolve_lifetimes(tcx: TyCtxt<'_>, for_krate: CrateNum) -> &ResolveLifetimes
|
||||
map.insert(hir_id.local_id, v);
|
||||
}
|
||||
|
||||
tcx.arena.alloc(rl)
|
||||
rl
|
||||
}
|
||||
|
||||
fn krate(tcx: TyCtxt<'_>) -> NamedRegionMap {
|
||||
|
@ -254,7 +254,7 @@ fn fulfill_implication<'a, 'tcx>(
|
||||
pub(super) fn specialization_graph_provider(
|
||||
tcx: TyCtxt<'_>,
|
||||
trait_id: DefId,
|
||||
) -> &specialization_graph::Graph {
|
||||
) -> specialization_graph::Graph {
|
||||
let mut sg = specialization_graph::Graph::new();
|
||||
|
||||
let mut trait_impls: Vec<_> = tcx.all_impls(trait_id).collect();
|
||||
@ -286,7 +286,7 @@ pub(super) fn specialization_graph_provider(
|
||||
}
|
||||
}
|
||||
|
||||
tcx.arena.alloc(sg)
|
||||
sg
|
||||
}
|
||||
|
||||
fn report_overlap_conflict(
|
||||
|
@ -220,9 +220,9 @@ fn associated_item_def_ids(tcx: TyCtxt<'_>, def_id: DefId) -> &[DefId] {
|
||||
}
|
||||
}
|
||||
|
||||
fn associated_items(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::AssociatedItems {
|
||||
fn associated_items(tcx: TyCtxt<'_>, def_id: DefId) -> ty::AssociatedItems {
|
||||
let items = tcx.associated_item_def_ids(def_id).iter().map(|did| tcx.associated_item(*did));
|
||||
tcx.arena.alloc(ty::AssociatedItems::new(items))
|
||||
ty::AssociatedItems::new(items)
|
||||
}
|
||||
|
||||
fn def_span(tcx: TyCtxt<'_>, def_id: DefId) -> Span {
|
||||
|
@ -17,13 +17,13 @@ use rustc_ast::ast;
|
||||
use rustc_span::Span;
|
||||
|
||||
/// On-demand query: yields a map containing all types mapped to their inherent impls.
|
||||
pub fn crate_inherent_impls(tcx: TyCtxt<'_>, crate_num: CrateNum) -> &CrateInherentImpls {
|
||||
pub fn crate_inherent_impls(tcx: TyCtxt<'_>, crate_num: CrateNum) -> CrateInherentImpls {
|
||||
assert_eq!(crate_num, LOCAL_CRATE);
|
||||
|
||||
let krate = tcx.hir().krate();
|
||||
let mut collect = InherentCollect { tcx, impls_map: Default::default() };
|
||||
krate.visit_all_item_likes(&mut collect);
|
||||
tcx.arena.alloc(collect.impls_map)
|
||||
collect.impls_map
|
||||
}
|
||||
|
||||
/// On-demand query: yields a vector of the inherent impls for a specific type.
|
||||
|
@ -861,7 +861,7 @@ fn convert_variant(
|
||||
)
|
||||
}
|
||||
|
||||
fn adt_def(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::AdtDef {
|
||||
fn adt_def(tcx: TyCtxt<'_>, def_id: DefId) -> ty::AdtDef {
|
||||
use rustc_hir::*;
|
||||
|
||||
let def_id = def_id.expect_local();
|
||||
@ -1002,7 +1002,7 @@ fn super_predicates_of(tcx: TyCtxt<'_>, trait_def_id: DefId) -> ty::GenericPredi
|
||||
ty::GenericPredicates { parent: None, predicates: superbounds }
|
||||
}
|
||||
|
||||
fn trait_def(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::TraitDef {
|
||||
fn trait_def(tcx: TyCtxt<'_>, def_id: DefId) -> ty::TraitDef {
|
||||
let hir_id = tcx.hir().as_local_hir_id(def_id.expect_local());
|
||||
let item = tcx.hir().expect_item(hir_id);
|
||||
|
||||
@ -1033,16 +1033,7 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::TraitDef {
|
||||
ty::trait_def::TraitSpecializationKind::None
|
||||
};
|
||||
let def_path_hash = tcx.def_path_hash(def_id);
|
||||
let def = ty::TraitDef::new(
|
||||
def_id,
|
||||
unsafety,
|
||||
paren_sugar,
|
||||
is_auto,
|
||||
is_marker,
|
||||
spec_kind,
|
||||
def_path_hash,
|
||||
);
|
||||
tcx.arena.alloc(def)
|
||||
ty::TraitDef::new(def_id, unsafety, paren_sugar, is_auto, is_marker, spec_kind, def_path_hash)
|
||||
}
|
||||
|
||||
fn has_late_bound_regions<'tcx>(tcx: TyCtxt<'tcx>, node: Node<'tcx>) -> Option<Span> {
|
||||
@ -1158,7 +1149,7 @@ fn has_late_bound_regions<'tcx>(tcx: TyCtxt<'tcx>, node: Node<'tcx>) -> Option<S
|
||||
}
|
||||
}
|
||||
|
||||
fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::Generics {
|
||||
fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::Generics {
|
||||
use rustc_hir::*;
|
||||
|
||||
let hir_id = tcx.hir().as_local_hir_id(def_id.expect_local());
|
||||
@ -1403,14 +1394,14 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::Generics {
|
||||
|
||||
let param_def_id_to_index = params.iter().map(|param| (param.def_id, param.index)).collect();
|
||||
|
||||
tcx.arena.alloc(ty::Generics {
|
||||
ty::Generics {
|
||||
parent: parent_def_id,
|
||||
parent_count,
|
||||
params,
|
||||
param_def_id_to_index,
|
||||
has_self: has_self || parent_has_self,
|
||||
has_late_bound_regions: has_late_bound_regions(tcx, node),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn are_suggestable_generic_args(generic_args: &[hir::GenericArg<'_>]) -> bool {
|
||||
|
@ -58,7 +58,7 @@ fn inferred_outlives_of(tcx: TyCtxt<'_>, item_def_id: DefId) -> &[(ty::Predicate
|
||||
}
|
||||
}
|
||||
|
||||
fn inferred_outlives_crate(tcx: TyCtxt<'_>, crate_num: CrateNum) -> &CratePredicatesMap<'_> {
|
||||
fn inferred_outlives_crate(tcx: TyCtxt<'_>, crate_num: CrateNum) -> CratePredicatesMap<'_> {
|
||||
assert_eq!(crate_num, LOCAL_CRATE);
|
||||
|
||||
// Compute a map from each struct/enum/union S to the **explicit**
|
||||
@ -105,5 +105,5 @@ fn inferred_outlives_crate(tcx: TyCtxt<'_>, crate_num: CrateNum) -> &CratePredic
|
||||
})
|
||||
.collect();
|
||||
|
||||
tcx.arena.alloc(ty::CratePredicatesMap { predicates })
|
||||
ty::CratePredicatesMap { predicates }
|
||||
}
|
||||
|
@ -29,12 +29,12 @@ pub fn provide(providers: &mut Providers<'_>) {
|
||||
*providers = Providers { variances_of, crate_variances, ..*providers };
|
||||
}
|
||||
|
||||
fn crate_variances(tcx: TyCtxt<'_>, crate_num: CrateNum) -> &CrateVariancesMap<'_> {
|
||||
fn crate_variances(tcx: TyCtxt<'_>, crate_num: CrateNum) -> CrateVariancesMap<'_> {
|
||||
assert_eq!(crate_num, LOCAL_CRATE);
|
||||
let mut arena = arena::TypedArena::default();
|
||||
let terms_cx = terms::determine_parameters_to_be_inferred(tcx, &mut arena);
|
||||
let constraints_cx = constraints::add_constraints_from_crate(terms_cx);
|
||||
tcx.arena.alloc(solve::solve_constraints(constraints_cx))
|
||||
solve::solve_constraints(constraints_cx)
|
||||
}
|
||||
|
||||
fn variances_of(tcx: TyCtxt<'_>, item_def_id: DefId) -> &[ty::Variance] {
|
||||
|
Loading…
Reference in New Issue
Block a user