1
Fork 0

Separate Definitions and CrateStore from ResolverOutputs.

This commit is contained in:
Camille GILLOT 2021-07-14 00:48:51 +02:00
parent 1f34da9ec8
commit 47799de35a
8 changed files with 72 additions and 75 deletions

View file

@ -13,6 +13,7 @@ use rustc_data_structures::temp_dir::MaybeTempDir;
use rustc_errors::{Applicability, ErrorGuaranteed, MultiSpan, PResult}; use rustc_errors::{Applicability, ErrorGuaranteed, MultiSpan, PResult};
use rustc_expand::base::{ExtCtxt, LintStoreExpand, ResolverExpand}; use rustc_expand::base::{ExtCtxt, LintStoreExpand, ResolverExpand};
use rustc_hir::def_id::{StableCrateId, LOCAL_CRATE}; use rustc_hir::def_id::{StableCrateId, LOCAL_CRATE};
use rustc_hir::definitions::Definitions;
use rustc_hir::Crate; use rustc_hir::Crate;
use rustc_lint::{EarlyCheckNode, LintStore}; use rustc_lint::{EarlyCheckNode, LintStore};
use rustc_metadata::creader::CStore; use rustc_metadata::creader::CStore;
@ -28,7 +29,7 @@ use rustc_plugin_impl as plugin;
use rustc_query_impl::{OnDiskCache, Queries as TcxQueries}; use rustc_query_impl::{OnDiskCache, Queries as TcxQueries};
use rustc_resolve::{Resolver, ResolverArenas}; use rustc_resolve::{Resolver, ResolverArenas};
use rustc_session::config::{CrateType, Input, OutputFilenames, OutputType}; use rustc_session::config::{CrateType, Input, OutputFilenames, OutputType};
use rustc_session::cstore::{MetadataLoader, MetadataLoaderDyn}; use rustc_session::cstore::{CrateStoreDyn, MetadataLoader, MetadataLoaderDyn};
use rustc_session::output::{filename_for_input, filename_for_metadata}; use rustc_session::output::{filename_for_input, filename_for_metadata};
use rustc_session::search_paths::PathKind; use rustc_session::search_paths::PathKind;
use rustc_session::{Limit, Session}; use rustc_session::{Limit, Session};
@ -136,7 +137,9 @@ mod boxed_resolver {
f((&mut *resolver).as_mut().unwrap()) f((&mut *resolver).as_mut().unwrap())
} }
pub fn to_resolver_outputs(resolver: Rc<RefCell<BoxedResolver>>) -> ResolverOutputs { pub fn to_resolver_outputs(
resolver: Rc<RefCell<BoxedResolver>>,
) -> (Definitions, Box<CrateStoreDyn>, ResolverOutputs) {
match Rc::try_unwrap(resolver) { match Rc::try_unwrap(resolver) {
Ok(resolver) => { Ok(resolver) => {
let mut resolver = resolver.into_inner(); let mut resolver = resolver.into_inner();
@ -826,7 +829,7 @@ pub fn create_global_ctxt<'tcx>(
let sess = &compiler.session(); let sess = &compiler.session();
let krate = let krate =
resolver.borrow_mut().access(|resolver| lower_to_hir(sess, resolver, krate, hir_arena)); resolver.borrow_mut().access(|resolver| lower_to_hir(sess, resolver, krate, hir_arena));
let resolver_outputs = BoxedResolver::to_resolver_outputs(resolver); let (definitions, cstore, resolver_outputs) = BoxedResolver::to_resolver_outputs(resolver);
let query_result_on_disk_cache = rustc_incremental::load_query_result_cache(sess); let query_result_on_disk_cache = rustc_incremental::load_query_result_cache(sess);
@ -851,6 +854,8 @@ pub fn create_global_ctxt<'tcx>(
sess, sess,
lint_store, lint_store,
arena, arena,
definitions,
cstore,
resolver_outputs, resolver_outputs,
krate, krate,
dep_graph, dep_graph,

View file

@ -429,7 +429,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
} }
fn encode_def_path_table(&mut self) { fn encode_def_path_table(&mut self) {
let table = self.tcx.resolutions(()).definitions.def_path_table(); let table = self.tcx.definitions_untracked().def_path_table();
if self.is_proc_macro { if self.is_proc_macro {
for def_index in std::iter::once(CRATE_DEF_INDEX) for def_index in std::iter::once(CRATE_DEF_INDEX)
.chain(self.tcx.resolutions(()).proc_macros.iter().map(|p| p.local_def_index)) .chain(self.tcx.resolutions(()).proc_macros.iter().map(|p| p.local_def_index))
@ -450,7 +450,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
fn encode_def_path_hash_map(&mut self) -> LazyValue<DefPathHashMapRef<'static>> { fn encode_def_path_hash_map(&mut self) -> LazyValue<DefPathHashMapRef<'static>> {
self.lazy(DefPathHashMapRef::BorrowedFromTcx( self.lazy(DefPathHashMapRef::BorrowedFromTcx(
self.tcx.resolutions(()).definitions.def_path_hash_to_def_index_map(), self.tcx.definitions_untracked().def_path_hash_to_def_index_map(),
)) ))
} }

View file

@ -170,7 +170,7 @@ impl<'hir> Map<'hir> {
pub fn def_key(self, def_id: LocalDefId) -> DefKey { pub fn def_key(self, def_id: LocalDefId) -> DefKey {
// Accessing the DefKey is ok, since it is part of DefPathHash. // Accessing the DefKey is ok, since it is part of DefPathHash.
self.tcx.untracked_resolutions.definitions.def_key(def_id) self.tcx.definitions_untracked().def_key(def_id)
} }
pub fn def_path_from_hir_id(self, id: HirId) -> Option<DefPath> { pub fn def_path_from_hir_id(self, id: HirId) -> Option<DefPath> {
@ -179,13 +179,13 @@ impl<'hir> Map<'hir> {
pub fn def_path(self, def_id: LocalDefId) -> DefPath { pub fn def_path(self, def_id: LocalDefId) -> DefPath {
// Accessing the DefPath is ok, since it is part of DefPathHash. // Accessing the DefPath is ok, since it is part of DefPathHash.
self.tcx.untracked_resolutions.definitions.def_path(def_id) self.tcx.definitions_untracked().def_path(def_id)
} }
#[inline] #[inline]
pub fn def_path_hash(self, def_id: LocalDefId) -> DefPathHash { pub fn def_path_hash(self, def_id: LocalDefId) -> DefPathHash {
// Accessing the DefPathHash is ok, it is incr. comp. stable. // Accessing the DefPathHash is ok, it is incr. comp. stable.
self.tcx.untracked_resolutions.definitions.def_path_hash(def_id) self.tcx.definitions_untracked().def_path_hash(def_id)
} }
#[inline] #[inline]
@ -222,7 +222,7 @@ impl<'hir> Map<'hir> {
// Create a dependency to the crate to be sure we re-execute this when the amount of // Create a dependency to the crate to be sure we re-execute this when the amount of
// definitions change. // definitions change.
self.tcx.ensure().hir_crate(()); self.tcx.ensure().hir_crate(());
self.tcx.untracked_resolutions.definitions.iter_local_def_id() self.tcx.definitions_untracked().iter_local_def_id()
} }
pub fn opt_def_kind(self, local_def_id: LocalDefId) -> Option<DefKind> { pub fn opt_def_kind(self, local_def_id: LocalDefId) -> Option<DefKind> {
@ -1100,7 +1100,7 @@ pub(super) fn crate_hash(tcx: TyCtxt<'_>, crate_num: CrateNum) -> Svh {
upstream_crates.hash_stable(&mut hcx, &mut stable_hasher); upstream_crates.hash_stable(&mut hcx, &mut stable_hasher);
source_file_names.hash_stable(&mut hcx, &mut stable_hasher); source_file_names.hash_stable(&mut hcx, &mut stable_hasher);
if tcx.sess.opts.debugging_opts.incremental_relative_spans { if tcx.sess.opts.debugging_opts.incremental_relative_spans {
let definitions = &tcx.untracked_resolutions.definitions; let definitions = &tcx.definitions_untracked();
let mut owner_spans: Vec<_> = krate let mut owner_spans: Vec<_> = krate
.owners .owners
.iter_enumerated() .iter_enumerated()
@ -1131,7 +1131,7 @@ fn upstream_crates(tcx: TyCtxt<'_>) -> Vec<(StableCrateId, Svh)> {
.crates(()) .crates(())
.iter() .iter()
.map(|&cnum| { .map(|&cnum| {
let stable_crate_id = tcx.resolutions(()).cstore.stable_crate_id(cnum); let stable_crate_id = tcx.stable_crate_id(cnum);
let hash = tcx.crate_hash(cnum); let hash = tcx.crate_hash(cnum);
(stable_crate_id, hash) (stable_crate_id, hash)
}) })

View file

@ -7,7 +7,7 @@ pub mod nested_filter;
pub mod place; pub mod place;
use crate::ty::query::Providers; use crate::ty::query::Providers;
use crate::ty::{ImplSubject, TyCtxt}; use crate::ty::{DefIdTree, ImplSubject, TyCtxt};
use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fingerprint::Fingerprint;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_hir::def_id::{DefId, LocalDefId};
@ -104,23 +104,20 @@ pub fn provide(providers: &mut Providers) {
}; };
providers.hir_owner_nodes = |tcx, id| tcx.hir_crate(()).owners[id].map(|i| &i.nodes); providers.hir_owner_nodes = |tcx, id| tcx.hir_crate(()).owners[id].map(|i| &i.nodes);
providers.hir_owner_parent = |tcx, id| { providers.hir_owner_parent = |tcx, id| {
// Accessing the def_key is ok since its value is hashed as part of `id`'s DefPathHash. // Accessing the local_parent is ok since its value is hashed as part of `id`'s DefPathHash.
let parent = tcx.untracked_resolutions.definitions.def_key(id).parent; tcx.opt_local_parent(id).map_or(CRATE_HIR_ID, |parent| {
let parent = parent.map_or(CRATE_HIR_ID, |local_def_index| { let mut parent_hir_id = tcx.hir().local_def_id_to_hir_id(parent);
let def_id = LocalDefId { local_def_index };
let mut parent_hir_id = tcx.hir().local_def_id_to_hir_id(def_id);
if let Some(local_id) = if let Some(local_id) =
tcx.hir_crate(()).owners[parent_hir_id.owner].unwrap().parenting.get(&id) tcx.hir_crate(()).owners[parent_hir_id.owner].unwrap().parenting.get(&id)
{ {
parent_hir_id.local_id = *local_id; parent_hir_id.local_id = *local_id;
} }
parent_hir_id parent_hir_id
}); })
parent
}; };
providers.hir_attrs = providers.hir_attrs =
|tcx, id| tcx.hir_crate(()).owners[id].as_owner().map_or(AttributeMap::EMPTY, |o| &o.attrs); |tcx, id| tcx.hir_crate(()).owners[id].as_owner().map_or(AttributeMap::EMPTY, |o| &o.attrs);
providers.source_span = |tcx, def_id| tcx.resolutions(()).definitions.def_span(def_id); providers.source_span = |tcx, def_id| tcx.definitions_untracked().def_span(def_id);
providers.def_span = |tcx, def_id| { providers.def_span = |tcx, def_id| {
let def_id = def_id.expect_local(); let def_id = def_id.expect_local();
let hir_id = tcx.hir().local_def_id_to_hir_id(def_id); let hir_id = tcx.hir().local_def_id_to_hir_id(def_id);
@ -150,7 +147,7 @@ pub fn provide(providers: &mut Providers) {
providers.all_local_trait_impls = |tcx, ()| &tcx.resolutions(()).trait_impls; providers.all_local_trait_impls = |tcx, ()| &tcx.resolutions(()).trait_impls;
providers.expn_that_defined = |tcx, id| { providers.expn_that_defined = |tcx, id| {
let id = id.expect_local(); let id = id.expect_local();
tcx.resolutions(()).definitions.expansion_that_defined(id) tcx.definitions_untracked().expansion_that_defined(id)
}; };
providers.in_scope_traits_map = providers.in_scope_traits_map =
|tcx, id| tcx.hir_crate(()).owners[id].as_owner().map(|owner_info| &owner_info.trait_map); |tcx, id| tcx.hir_crate(()).owners[id].as_owner().map(|owner_info| &owner_info.trait_map);

View file

@ -31,6 +31,7 @@ rustc_queries! {
/// This span is meant for dep-tracking rather than diagnostics. It should not be used outside /// This span is meant for dep-tracking rather than diagnostics. It should not be used outside
/// of rustc_middle::hir::source_map. /// of rustc_middle::hir::source_map.
query source_span(key: LocalDefId) -> Span { query source_span(key: LocalDefId) -> Span {
eval_always
desc { "get the source span" } desc { "get the source span" }
} }

View file

@ -50,6 +50,7 @@ use rustc_middle::mir::FakeReadCause;
use rustc_query_system::ich::StableHashingContext; use rustc_query_system::ich::StableHashingContext;
use rustc_serialize::opaque::{FileEncodeResult, FileEncoder}; use rustc_serialize::opaque::{FileEncodeResult, FileEncoder};
use rustc_session::config::{CrateType, OutputFilenames}; use rustc_session::config::{CrateType, OutputFilenames};
use rustc_session::cstore::CrateStoreDyn;
use rustc_session::lint::{Level, Lint}; use rustc_session::lint::{Level, Lint};
use rustc_session::Limit; use rustc_session::Limit;
use rustc_session::Session; use rustc_session::Session;
@ -177,7 +178,8 @@ impl<'tcx> CtxtInterners<'tcx> {
&self, &self,
kind: TyKind<'tcx>, kind: TyKind<'tcx>,
sess: &Session, sess: &Session,
resolutions: &ty::ResolverOutputs, definitions: &rustc_hir::definitions::Definitions,
cstore: &CrateStoreDyn,
) -> Ty<'tcx> { ) -> Ty<'tcx> {
Ty(Interned::new_unchecked( Ty(Interned::new_unchecked(
self.type_ self.type_
@ -192,11 +194,7 @@ impl<'tcx> CtxtInterners<'tcx> {
Fingerprint::ZERO Fingerprint::ZERO
} else { } else {
let mut hasher = StableHasher::new(); let mut hasher = StableHasher::new();
let mut hcx = StableHashingContext::ignore_spans( let mut hcx = StableHashingContext::ignore_spans(sess, definitions, cstore);
sess,
&resolutions.definitions,
&*resolutions.cstore,
);
kind.hash_stable(&mut hcx, &mut hasher); kind.hash_stable(&mut hcx, &mut hasher);
hasher.finish() hasher.finish()
}; };
@ -934,9 +932,10 @@ impl<'tcx> CommonTypes<'tcx> {
fn new( fn new(
interners: &CtxtInterners<'tcx>, interners: &CtxtInterners<'tcx>,
sess: &Session, sess: &Session,
resolutions: &ty::ResolverOutputs, definitions: &rustc_hir::definitions::Definitions,
cstore: &CrateStoreDyn,
) -> CommonTypes<'tcx> { ) -> CommonTypes<'tcx> {
let mk = |ty| interners.intern_ty(ty, sess, resolutions); let mk = |ty| interners.intern_ty(ty, sess, definitions, cstore);
CommonTypes { CommonTypes {
unit: mk(Tuple(List::empty())), unit: mk(Tuple(List::empty())),
@ -1057,6 +1056,9 @@ pub struct GlobalCtxt<'tcx> {
/// Common consts, pre-interned for your convenience. /// Common consts, pre-interned for your convenience.
pub consts: CommonConsts<'tcx>, pub consts: CommonConsts<'tcx>,
definitions: rustc_hir::definitions::Definitions,
cstore: Box<CrateStoreDyn>,
/// Output of the resolver. /// Output of the resolver.
pub(crate) untracked_resolutions: ty::ResolverOutputs, pub(crate) untracked_resolutions: ty::ResolverOutputs,
@ -1218,7 +1220,9 @@ impl<'tcx> TyCtxt<'tcx> {
s: &'tcx Session, s: &'tcx Session,
lint_store: Lrc<dyn Any + sync::Send + sync::Sync>, lint_store: Lrc<dyn Any + sync::Send + sync::Sync>,
arena: &'tcx WorkerLocal<Arena<'tcx>>, arena: &'tcx WorkerLocal<Arena<'tcx>>,
resolutions: ty::ResolverOutputs, definitions: rustc_hir::definitions::Definitions,
cstore: Box<CrateStoreDyn>,
untracked_resolutions: ty::ResolverOutputs,
krate: &'tcx hir::Crate<'tcx>, krate: &'tcx hir::Crate<'tcx>,
dep_graph: DepGraph, dep_graph: DepGraph,
on_disk_cache: Option<&'tcx dyn OnDiskCache<'tcx>>, on_disk_cache: Option<&'tcx dyn OnDiskCache<'tcx>>,
@ -1231,7 +1235,7 @@ impl<'tcx> TyCtxt<'tcx> {
s.fatal(&err); s.fatal(&err);
}); });
let interners = CtxtInterners::new(arena); let interners = CtxtInterners::new(arena);
let common_types = CommonTypes::new(&interners, s, &resolutions); let common_types = CommonTypes::new(&interners, s, &definitions, &*cstore);
let common_lifetimes = CommonLifetimes::new(&interners); let common_lifetimes = CommonLifetimes::new(&interners);
let common_consts = CommonConsts::new(&interners, &common_types); let common_consts = CommonConsts::new(&interners, &common_types);
@ -1241,7 +1245,9 @@ impl<'tcx> TyCtxt<'tcx> {
arena, arena,
interners, interners,
dep_graph, dep_graph,
untracked_resolutions: resolutions, definitions,
cstore,
untracked_resolutions,
prof: s.prof.clone(), prof: s.prof.clone(),
types: common_types, types: common_types,
lifetimes: common_lifetimes, lifetimes: common_lifetimes,
@ -1342,9 +1348,9 @@ impl<'tcx> TyCtxt<'tcx> {
pub fn def_key(self, id: DefId) -> rustc_hir::definitions::DefKey { pub fn def_key(self, id: DefId) -> rustc_hir::definitions::DefKey {
// Accessing the DefKey is ok, since it is part of DefPathHash. // Accessing the DefKey is ok, since it is part of DefPathHash.
if let Some(id) = id.as_local() { if let Some(id) = id.as_local() {
self.untracked_resolutions.definitions.def_key(id) self.definitions.def_key(id)
} else { } else {
self.untracked_resolutions.cstore.def_key(id) self.cstore.def_key(id)
} }
} }
@ -1356,9 +1362,9 @@ impl<'tcx> TyCtxt<'tcx> {
pub fn def_path(self, id: DefId) -> rustc_hir::definitions::DefPath { pub fn def_path(self, id: DefId) -> rustc_hir::definitions::DefPath {
// Accessing the DefPath is ok, since it is part of DefPathHash. // Accessing the DefPath is ok, since it is part of DefPathHash.
if let Some(id) = id.as_local() { if let Some(id) = id.as_local() {
self.untracked_resolutions.definitions.def_path(id) self.definitions.def_path(id)
} else { } else {
self.untracked_resolutions.cstore.def_path(id) self.cstore.def_path(id)
} }
} }
@ -1366,9 +1372,9 @@ impl<'tcx> TyCtxt<'tcx> {
pub fn def_path_hash(self, def_id: DefId) -> rustc_hir::definitions::DefPathHash { pub fn def_path_hash(self, def_id: DefId) -> rustc_hir::definitions::DefPathHash {
// Accessing the DefPathHash is ok, it is incr. comp. stable. // Accessing the DefPathHash is ok, it is incr. comp. stable.
if let Some(def_id) = def_id.as_local() { if let Some(def_id) = def_id.as_local() {
self.untracked_resolutions.definitions.def_path_hash(def_id) self.definitions.def_path_hash(def_id)
} else { } else {
self.untracked_resolutions.cstore.def_path_hash(def_id) self.cstore.def_path_hash(def_id)
} }
} }
@ -1377,7 +1383,7 @@ impl<'tcx> TyCtxt<'tcx> {
if crate_num == LOCAL_CRATE { if crate_num == LOCAL_CRATE {
self.sess.local_stable_crate_id() self.sess.local_stable_crate_id()
} else { } else {
self.untracked_resolutions.cstore.stable_crate_id(crate_num) self.cstore.stable_crate_id(crate_num)
} }
} }
@ -1388,7 +1394,7 @@ impl<'tcx> TyCtxt<'tcx> {
if stable_crate_id == self.sess.local_stable_crate_id() { if stable_crate_id == self.sess.local_stable_crate_id() {
LOCAL_CRATE LOCAL_CRATE
} else { } else {
self.untracked_resolutions.cstore.stable_crate_id_to_crate_num(stable_crate_id) self.cstore.stable_crate_id_to_crate_num(stable_crate_id)
} }
} }
@ -1403,16 +1409,12 @@ impl<'tcx> TyCtxt<'tcx> {
// If this is a DefPathHash from the local crate, we can look up the // If this is a DefPathHash from the local crate, we can look up the
// DefId in the tcx's `Definitions`. // DefId in the tcx's `Definitions`.
if stable_crate_id == self.sess.local_stable_crate_id() { if stable_crate_id == self.sess.local_stable_crate_id() {
self.untracked_resolutions self.definitions.local_def_path_hash_to_def_id(hash, err).to_def_id()
.definitions
.local_def_path_hash_to_def_id(hash, err)
.to_def_id()
} else { } else {
// If this is a DefPathHash from an upstream crate, let the CrateStore map // If this is a DefPathHash from an upstream crate, let the CrateStore map
// it to a DefId. // it to a DefId.
let cstore = &self.untracked_resolutions.cstore; let cnum = self.cstore.stable_crate_id_to_crate_num(stable_crate_id);
let cnum = cstore.stable_crate_id_to_crate_num(stable_crate_id); self.cstore.def_path_hash_to_def_id(cnum, hash)
cstore.def_path_hash_to_def_id(cnum, hash)
} }
} }
@ -1424,7 +1426,7 @@ impl<'tcx> TyCtxt<'tcx> {
let (crate_name, stable_crate_id) = if def_id.is_local() { let (crate_name, stable_crate_id) = if def_id.is_local() {
(self.crate_name, self.sess.local_stable_crate_id()) (self.crate_name, self.sess.local_stable_crate_id())
} else { } else {
let cstore = &self.untracked_resolutions.cstore; let cstore = &self.cstore;
(cstore.crate_name(def_id.krate), cstore.stable_crate_id(def_id.krate)) (cstore.crate_name(def_id.krate), cstore.stable_crate_id(def_id.krate))
}; };
@ -1440,30 +1442,24 @@ impl<'tcx> TyCtxt<'tcx> {
/// Note that this is *untracked* and should only be used within the query /// Note that this is *untracked* and should only be used within the query
/// system if the result is otherwise tracked through queries /// system if the result is otherwise tracked through queries
pub fn cstore_untracked(self) -> &'tcx ty::CrateStoreDyn { pub fn cstore_untracked(self) -> &'tcx CrateStoreDyn {
&*self.untracked_resolutions.cstore &*self.cstore
} }
/// Note that this is *untracked* and should only be used within the query /// Note that this is *untracked* and should only be used within the query
/// system if the result is otherwise tracked through queries /// system if the result is otherwise tracked through queries
pub fn definitions_untracked(self) -> &'tcx hir::definitions::Definitions { pub fn definitions_untracked(self) -> &'tcx hir::definitions::Definitions {
&self.untracked_resolutions.definitions &self.definitions
} }
#[inline(always)] #[inline(always)]
pub fn create_stable_hashing_context(self) -> StableHashingContext<'tcx> { pub fn create_stable_hashing_context(self) -> StableHashingContext<'tcx> {
let resolutions = &self.gcx.untracked_resolutions; StableHashingContext::new(self.sess, &self.definitions, &*self.cstore)
StableHashingContext::new(self.sess, &resolutions.definitions, &*resolutions.cstore)
} }
#[inline(always)] #[inline(always)]
pub fn create_no_span_stable_hashing_context(self) -> StableHashingContext<'tcx> { pub fn create_no_span_stable_hashing_context(self) -> StableHashingContext<'tcx> {
let resolutions = &self.gcx.untracked_resolutions; StableHashingContext::ignore_spans(self.sess, &self.definitions, &*self.cstore)
StableHashingContext::ignore_spans(
self.sess,
&resolutions.definitions,
&*resolutions.cstore,
)
} }
pub fn serialize_query_result_cache(self, encoder: FileEncoder) -> FileEncodeResult { pub fn serialize_query_result_cache(self, encoder: FileEncoder) -> FileEncodeResult {
@ -2254,7 +2250,7 @@ impl<'tcx> TyCtxt<'tcx> {
#[allow(rustc::usage_of_ty_tykind)] #[allow(rustc::usage_of_ty_tykind)]
#[inline] #[inline]
pub fn mk_ty(self, st: TyKind<'tcx>) -> Ty<'tcx> { pub fn mk_ty(self, st: TyKind<'tcx>) -> Ty<'tcx> {
self.interners.intern_ty(st, self.sess, &self.gcx.untracked_resolutions) self.interners.intern_ty(st, self.sess, &self.definitions, &*self.cstore)
} }
#[inline] #[inline]

View file

@ -39,7 +39,6 @@ use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LocalDefIdMap};
use rustc_hir::Node; use rustc_hir::Node;
use rustc_macros::HashStable; use rustc_macros::HashStable;
use rustc_query_system::ich::StableHashingContext; use rustc_query_system::ich::StableHashingContext;
use rustc_session::cstore::CrateStoreDyn;
use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::Span; use rustc_span::Span;
use rustc_target::abi::{Align, VariantIdx}; use rustc_target::abi::{Align, VariantIdx};
@ -133,8 +132,6 @@ pub type RegisteredTools = FxHashSet<Ident>;
#[derive(Debug)] #[derive(Debug)]
pub struct ResolverOutputs { pub struct ResolverOutputs {
pub definitions: rustc_hir::definitions::Definitions,
pub cstore: Box<CrateStoreDyn>,
pub visibilities: FxHashMap<LocalDefId, Visibility>, pub visibilities: FxHashMap<LocalDefId, Visibility>,
/// This field is used to decide whether we should make `PRIVATE_IN_PUBLIC` a hard error. /// This field is used to decide whether we should make `PRIVATE_IN_PUBLIC` a hard error.
pub has_pub_restricted: bool, pub has_pub_restricted: bool,

View file

@ -47,7 +47,7 @@ use rustc_middle::span_bug;
use rustc_middle::ty::query::Providers; use rustc_middle::ty::query::Providers;
use rustc_middle::ty::{self, DefIdTree, MainDefinition, RegisteredTools, ResolverOutputs}; use rustc_middle::ty::{self, DefIdTree, MainDefinition, RegisteredTools, ResolverOutputs};
use rustc_query_system::ich::StableHashingContext; use rustc_query_system::ich::StableHashingContext;
use rustc_session::cstore::{CrateStore, MetadataLoaderDyn}; use rustc_session::cstore::{CrateStore, CrateStoreDyn, MetadataLoaderDyn};
use rustc_session::lint::LintBuffer; use rustc_session::lint::LintBuffer;
use rustc_session::Session; use rustc_session::Session;
use rustc_span::hygiene::{ExpnId, LocalExpnId, MacroKind, SyntaxContext, Transparency}; use rustc_span::hygiene::{ExpnId, LocalExpnId, MacroKind, SyntaxContext, Transparency};
@ -1439,9 +1439,10 @@ impl<'a> Resolver<'a> {
Default::default() Default::default()
} }
pub fn into_outputs(self) -> ResolverOutputs { pub fn into_outputs(self) -> (Definitions, Box<CrateStoreDyn>, ResolverOutputs) {
let proc_macros = self.proc_macros.iter().map(|id| self.local_def_id(*id)).collect(); let proc_macros = self.proc_macros.iter().map(|id| self.local_def_id(*id)).collect();
let definitions = self.definitions; let definitions = self.definitions;
let cstore = Box::new(self.crate_loader.into_cstore());
let visibilities = self.visibilities; let visibilities = self.visibilities;
let has_pub_restricted = self.has_pub_restricted; let has_pub_restricted = self.has_pub_restricted;
let extern_crate_map = self.extern_crate_map; let extern_crate_map = self.extern_crate_map;
@ -1452,9 +1453,7 @@ impl<'a> Resolver<'a> {
let main_def = self.main_def; let main_def = self.main_def;
let confused_type_with_std_module = self.confused_type_with_std_module; let confused_type_with_std_module = self.confused_type_with_std_module;
let access_levels = self.access_levels; let access_levels = self.access_levels;
ResolverOutputs { let resolutions = ResolverOutputs {
definitions,
cstore: Box::new(self.crate_loader.into_cstore()),
visibilities, visibilities,
has_pub_restricted, has_pub_restricted,
access_levels, access_levels,
@ -1473,15 +1472,15 @@ impl<'a> Resolver<'a> {
proc_macros, proc_macros,
confused_type_with_std_module, confused_type_with_std_module,
registered_tools: self.registered_tools, registered_tools: self.registered_tools,
} };
(definitions, cstore, resolutions)
} }
pub fn clone_outputs(&self) -> ResolverOutputs { pub fn clone_outputs(&self) -> (Definitions, Box<CrateStoreDyn>, ResolverOutputs) {
let proc_macros = self.proc_macros.iter().map(|id| self.local_def_id(*id)).collect(); let proc_macros = self.proc_macros.iter().map(|id| self.local_def_id(*id)).collect();
ResolverOutputs { let definitions = self.definitions.clone();
definitions: self.definitions.clone(), let cstore = Box::new(self.cstore().clone());
access_levels: self.access_levels.clone(), let resolutions = ResolverOutputs {
cstore: Box::new(self.cstore().clone()),
visibilities: self.visibilities.clone(), visibilities: self.visibilities.clone(),
has_pub_restricted: self.has_pub_restricted, has_pub_restricted: self.has_pub_restricted,
extern_crate_map: self.extern_crate_map.clone(), extern_crate_map: self.extern_crate_map.clone(),
@ -1499,7 +1498,9 @@ impl<'a> Resolver<'a> {
proc_macros, proc_macros,
confused_type_with_std_module: self.confused_type_with_std_module.clone(), confused_type_with_std_module: self.confused_type_with_std_module.clone(),
registered_tools: self.registered_tools.clone(), registered_tools: self.registered_tools.clone(),
} access_levels: self.access_levels.clone(),
};
(definitions, cstore, resolutions)
} }
pub fn cstore(&self) -> &CStore { pub fn cstore(&self) -> &CStore {