Move the untracked cstore and source_span into a struct
This commit is contained in:
parent
2cd36f2c89
commit
1c1d3570ee
16 changed files with 78 additions and 91 deletions
|
@ -4342,6 +4342,7 @@ dependencies = [
|
||||||
"rustc_feature",
|
"rustc_feature",
|
||||||
"rustc_fs_util",
|
"rustc_fs_util",
|
||||||
"rustc_hir",
|
"rustc_hir",
|
||||||
|
"rustc_index",
|
||||||
"rustc_lint_defs",
|
"rustc_lint_defs",
|
||||||
"rustc_macros",
|
"rustc_macros",
|
||||||
"rustc_serialize",
|
"rustc_serialize",
|
||||||
|
|
|
@ -808,6 +808,7 @@ pub fn create_global_ctxt<'tcx>(
|
||||||
definitions,
|
definitions,
|
||||||
global_ctxt: untracked_resolutions,
|
global_ctxt: untracked_resolutions,
|
||||||
ast_lowering: untracked_resolver_for_lowering,
|
ast_lowering: untracked_resolver_for_lowering,
|
||||||
|
untracked,
|
||||||
} = resolver_outputs;
|
} = resolver_outputs;
|
||||||
|
|
||||||
let gcx = sess.time("setup_global_ctxt", || {
|
let gcx = sess.time("setup_global_ctxt", || {
|
||||||
|
@ -819,6 +820,7 @@ pub fn create_global_ctxt<'tcx>(
|
||||||
hir_arena,
|
hir_arena,
|
||||||
definitions,
|
definitions,
|
||||||
untracked_resolutions,
|
untracked_resolutions,
|
||||||
|
untracked,
|
||||||
krate,
|
krate,
|
||||||
dep_graph,
|
dep_graph,
|
||||||
queries.on_disk_cache.as_ref().map(OnDiskCache::as_dyn),
|
queries.on_disk_cache.as_ref().map(OnDiskCache::as_dyn),
|
||||||
|
|
|
@ -629,6 +629,9 @@ impl CrateStore for CStore {
|
||||||
fn as_any(&self) -> &dyn Any {
|
fn as_any(&self) -> &dyn Any {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
fn untracked_as_any(&mut self) -> &mut dyn Any {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
fn crate_name(&self, cnum: CrateNum) -> Symbol {
|
fn crate_name(&self, cnum: CrateNum) -> Symbol {
|
||||||
self.get_crate_data(cnum).root.name
|
self.get_crate_data(cnum).root.name
|
||||||
|
|
|
@ -14,7 +14,7 @@ use rustc_index::vec::Idx;
|
||||||
use rustc_middle::hir::nested_filter;
|
use rustc_middle::hir::nested_filter;
|
||||||
use rustc_span::def_id::StableCrateId;
|
use rustc_span::def_id::StableCrateId;
|
||||||
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
||||||
use rustc_span::{Span, DUMMY_SP};
|
use rustc_span::Span;
|
||||||
use rustc_target::spec::abi::Abi;
|
use rustc_target::spec::abi::Abi;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -1162,7 +1162,7 @@ pub(super) fn crate_hash(tcx: TyCtxt<'_>, crate_num: CrateNum) -> Svh {
|
||||||
.filter_map(|(def_id, info)| {
|
.filter_map(|(def_id, info)| {
|
||||||
let _ = info.as_owner()?;
|
let _ = info.as_owner()?;
|
||||||
let def_path_hash = definitions.def_path_hash(def_id);
|
let def_path_hash = definitions.def_path_hash(def_id);
|
||||||
let span = resolutions.source_span.get(def_id).unwrap_or(&DUMMY_SP);
|
let span = tcx.source_span(def_id);
|
||||||
debug_assert_eq!(span.parent(), None);
|
debug_assert_eq!(span.parent(), None);
|
||||||
Some((def_path_hash, span))
|
Some((def_path_hash, span))
|
||||||
})
|
})
|
||||||
|
|
|
@ -141,8 +141,6 @@ pub fn provide(providers: &mut Providers) {
|
||||||
providers.hir_attrs = |tcx, id| {
|
providers.hir_attrs = |tcx, id| {
|
||||||
tcx.hir_crate(()).owners[id.def_id].as_owner().map_or(AttributeMap::EMPTY, |o| &o.attrs)
|
tcx.hir_crate(()).owners[id.def_id].as_owner().map_or(AttributeMap::EMPTY, |o| &o.attrs)
|
||||||
};
|
};
|
||||||
providers.source_span =
|
|
||||||
|tcx, def_id| tcx.resolutions(()).source_span.get(def_id).copied().unwrap_or(DUMMY_SP);
|
|
||||||
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);
|
||||||
|
|
|
@ -43,6 +43,8 @@ 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 {
|
||||||
|
// Accesses untracked data
|
||||||
|
eval_always
|
||||||
desc { "getting the source span" }
|
desc { "getting the source span" }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ use rustc_query_system::dep_graph::DepNodeIndex;
|
||||||
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::cstore::{CrateStoreDyn, Untracked};
|
||||||
use rustc_session::lint::Lint;
|
use rustc_session::lint::Lint;
|
||||||
use rustc_session::Limit;
|
use rustc_session::Limit;
|
||||||
use rustc_session::Session;
|
use rustc_session::Session;
|
||||||
|
@ -187,15 +187,13 @@ impl<'tcx> CtxtInterners<'tcx> {
|
||||||
kind: TyKind<'tcx>,
|
kind: TyKind<'tcx>,
|
||||||
sess: &Session,
|
sess: &Session,
|
||||||
definitions: &rustc_hir::definitions::Definitions,
|
definitions: &rustc_hir::definitions::Definitions,
|
||||||
cstore: &CrateStoreDyn,
|
untracked: &Untracked,
|
||||||
source_span: &IndexVec<LocalDefId, Span>,
|
|
||||||
) -> Ty<'tcx> {
|
) -> Ty<'tcx> {
|
||||||
Ty(Interned::new_unchecked(
|
Ty(Interned::new_unchecked(
|
||||||
self.type_
|
self.type_
|
||||||
.intern(kind, |kind| {
|
.intern(kind, |kind| {
|
||||||
let flags = super::flags::FlagComputation::for_kind(&kind);
|
let flags = super::flags::FlagComputation::for_kind(&kind);
|
||||||
let stable_hash =
|
let stable_hash = self.stable_hash(&flags, sess, definitions, untracked, &kind);
|
||||||
self.stable_hash(&flags, sess, definitions, cstore, source_span, &kind);
|
|
||||||
|
|
||||||
InternedInSet(self.arena.alloc(WithCachedTypeInfo {
|
InternedInSet(self.arena.alloc(WithCachedTypeInfo {
|
||||||
internee: kind,
|
internee: kind,
|
||||||
|
@ -213,8 +211,7 @@ impl<'tcx> CtxtInterners<'tcx> {
|
||||||
flags: &ty::flags::FlagComputation,
|
flags: &ty::flags::FlagComputation,
|
||||||
sess: &'a Session,
|
sess: &'a Session,
|
||||||
definitions: &'a rustc_hir::definitions::Definitions,
|
definitions: &'a rustc_hir::definitions::Definitions,
|
||||||
cstore: &'a CrateStoreDyn,
|
untracked: &'a Untracked,
|
||||||
source_span: &'a IndexVec<LocalDefId, Span>,
|
|
||||||
val: &T,
|
val: &T,
|
||||||
) -> Fingerprint {
|
) -> Fingerprint {
|
||||||
// It's impossible to hash inference variables (and will ICE), so we don't need to try to cache them.
|
// It's impossible to hash inference variables (and will ICE), so we don't need to try to cache them.
|
||||||
|
@ -223,7 +220,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::new(sess, definitions, cstore, source_span);
|
let mut hcx = StableHashingContext::new(sess, definitions, untracked);
|
||||||
val.hash_stable(&mut hcx, &mut hasher);
|
val.hash_stable(&mut hcx, &mut hasher);
|
||||||
hasher.finish()
|
hasher.finish()
|
||||||
}
|
}
|
||||||
|
@ -235,16 +232,14 @@ impl<'tcx> CtxtInterners<'tcx> {
|
||||||
kind: Binder<'tcx, PredicateKind<'tcx>>,
|
kind: Binder<'tcx, PredicateKind<'tcx>>,
|
||||||
sess: &Session,
|
sess: &Session,
|
||||||
definitions: &rustc_hir::definitions::Definitions,
|
definitions: &rustc_hir::definitions::Definitions,
|
||||||
cstore: &CrateStoreDyn,
|
untracked: &Untracked,
|
||||||
source_span: &IndexVec<LocalDefId, Span>,
|
|
||||||
) -> Predicate<'tcx> {
|
) -> Predicate<'tcx> {
|
||||||
Predicate(Interned::new_unchecked(
|
Predicate(Interned::new_unchecked(
|
||||||
self.predicate
|
self.predicate
|
||||||
.intern(kind, |kind| {
|
.intern(kind, |kind| {
|
||||||
let flags = super::flags::FlagComputation::for_predicate(kind);
|
let flags = super::flags::FlagComputation::for_predicate(kind);
|
||||||
|
|
||||||
let stable_hash =
|
let stable_hash = self.stable_hash(&flags, sess, definitions, untracked, &kind);
|
||||||
self.stable_hash(&flags, sess, definitions, cstore, source_span, &kind);
|
|
||||||
|
|
||||||
InternedInSet(self.arena.alloc(WithCachedTypeInfo {
|
InternedInSet(self.arena.alloc(WithCachedTypeInfo {
|
||||||
internee: kind,
|
internee: kind,
|
||||||
|
@ -963,10 +958,9 @@ impl<'tcx> CommonTypes<'tcx> {
|
||||||
interners: &CtxtInterners<'tcx>,
|
interners: &CtxtInterners<'tcx>,
|
||||||
sess: &Session,
|
sess: &Session,
|
||||||
definitions: &rustc_hir::definitions::Definitions,
|
definitions: &rustc_hir::definitions::Definitions,
|
||||||
cstore: &CrateStoreDyn,
|
untracked: &Untracked,
|
||||||
source_span: &IndexVec<LocalDefId, Span>,
|
|
||||||
) -> CommonTypes<'tcx> {
|
) -> CommonTypes<'tcx> {
|
||||||
let mk = |ty| interners.intern_ty(ty, sess, definitions, cstore, source_span);
|
let mk = |ty| interners.intern_ty(ty, sess, definitions, untracked);
|
||||||
|
|
||||||
CommonTypes {
|
CommonTypes {
|
||||||
unit: mk(Tuple(List::empty())),
|
unit: mk(Tuple(List::empty())),
|
||||||
|
@ -1114,6 +1108,7 @@ pub struct GlobalCtxt<'tcx> {
|
||||||
|
|
||||||
definitions: RwLock<Definitions>,
|
definitions: RwLock<Definitions>,
|
||||||
|
|
||||||
|
untracked: Untracked,
|
||||||
/// Output of the resolver.
|
/// Output of the resolver.
|
||||||
pub(crate) untracked_resolutions: ty::ResolverGlobalCtxt,
|
pub(crate) untracked_resolutions: ty::ResolverGlobalCtxt,
|
||||||
/// The entire crate as AST. This field serves as the input for the hir_crate query,
|
/// The entire crate as AST. This field serves as the input for the hir_crate query,
|
||||||
|
@ -1280,6 +1275,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
hir_arena: &'tcx WorkerLocal<hir::Arena<'tcx>>,
|
hir_arena: &'tcx WorkerLocal<hir::Arena<'tcx>>,
|
||||||
definitions: Definitions,
|
definitions: Definitions,
|
||||||
untracked_resolutions: ty::ResolverGlobalCtxt,
|
untracked_resolutions: ty::ResolverGlobalCtxt,
|
||||||
|
untracked: Untracked,
|
||||||
krate: Lrc<ast::Crate>,
|
krate: Lrc<ast::Crate>,
|
||||||
dep_graph: DepGraph,
|
dep_graph: DepGraph,
|
||||||
on_disk_cache: Option<&'tcx dyn OnDiskCache<'tcx>>,
|
on_disk_cache: Option<&'tcx dyn OnDiskCache<'tcx>>,
|
||||||
|
@ -1292,14 +1288,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
s.emit_fatal(err);
|
s.emit_fatal(err);
|
||||||
});
|
});
|
||||||
let interners = CtxtInterners::new(arena);
|
let interners = CtxtInterners::new(arena);
|
||||||
let common_types = CommonTypes::new(
|
let common_types = CommonTypes::new(&interners, s, &definitions, &untracked);
|
||||||
&interners,
|
|
||||||
s,
|
|
||||||
&definitions,
|
|
||||||
&*untracked_resolutions.cstore,
|
|
||||||
// This is only used to create a stable hashing context.
|
|
||||||
&untracked_resolutions.source_span,
|
|
||||||
);
|
|
||||||
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);
|
||||||
|
|
||||||
|
@ -1315,6 +1304,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
types: common_types,
|
types: common_types,
|
||||||
lifetimes: common_lifetimes,
|
lifetimes: common_lifetimes,
|
||||||
consts: common_consts,
|
consts: common_consts,
|
||||||
|
untracked,
|
||||||
untracked_resolutions,
|
untracked_resolutions,
|
||||||
untracked_crate: Steal::new(krate),
|
untracked_crate: Steal::new(krate),
|
||||||
on_disk_cache,
|
on_disk_cache,
|
||||||
|
@ -1428,7 +1418,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
if let Some(id) = id.as_local() {
|
if let Some(id) = id.as_local() {
|
||||||
self.definitions_untracked().def_key(id)
|
self.definitions_untracked().def_key(id)
|
||||||
} else {
|
} else {
|
||||||
self.untracked_resolutions.cstore.def_key(id)
|
self.untracked.cstore.def_key(id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1442,7 +1432,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
if let Some(id) = id.as_local() {
|
if let Some(id) = id.as_local() {
|
||||||
self.definitions_untracked().def_path(id)
|
self.definitions_untracked().def_path(id)
|
||||||
} else {
|
} else {
|
||||||
self.untracked_resolutions.cstore.def_path(id)
|
self.untracked.cstore.def_path(id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1452,7 +1442,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
if let Some(def_id) = def_id.as_local() {
|
if let Some(def_id) = def_id.as_local() {
|
||||||
self.definitions_untracked().def_path_hash(def_id)
|
self.definitions_untracked().def_path_hash(def_id)
|
||||||
} else {
|
} else {
|
||||||
self.untracked_resolutions.cstore.def_path_hash(def_id)
|
self.untracked.cstore.def_path_hash(def_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1461,7 +1451,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.untracked.cstore.stable_crate_id(crate_num)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1472,7 +1462,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.untracked.cstore.stable_crate_id_to_crate_num(stable_crate_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1491,7 +1481,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
} 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 cstore = &*self.untracked.cstore;
|
||||||
let cnum = cstore.stable_crate_id_to_crate_num(stable_crate_id);
|
let cnum = cstore.stable_crate_id_to_crate_num(stable_crate_id);
|
||||||
cstore.def_path_hash_to_def_id(cnum, hash)
|
cstore.def_path_hash_to_def_id(cnum, hash)
|
||||||
}
|
}
|
||||||
|
@ -1505,7 +1495,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.untracked.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))
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1604,7 +1594,7 @@ 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 CrateStoreDyn {
|
pub fn cstore_untracked(self) -> &'tcx CrateStoreDyn {
|
||||||
&*self.untracked_resolutions.cstore
|
&*self.untracked.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
|
||||||
|
@ -1618,7 +1608,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
/// system if the result is otherwise tracked through queries
|
/// system if the result is otherwise tracked through queries
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn source_span_untracked(self, def_id: LocalDefId) -> Span {
|
pub fn source_span_untracked(self, def_id: LocalDefId) -> Span {
|
||||||
self.untracked_resolutions.source_span.get(def_id).copied().unwrap_or(DUMMY_SP)
|
self.untracked.source_span.get(def_id).copied().unwrap_or(DUMMY_SP)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
|
@ -1627,12 +1617,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
f: impl FnOnce(StableHashingContext<'_>) -> R,
|
f: impl FnOnce(StableHashingContext<'_>) -> R,
|
||||||
) -> R {
|
) -> R {
|
||||||
let definitions = self.definitions_untracked();
|
let definitions = self.definitions_untracked();
|
||||||
let hcx = StableHashingContext::new(
|
let hcx = StableHashingContext::new(self.sess, &*definitions, &self.untracked);
|
||||||
self.sess,
|
|
||||||
&*definitions,
|
|
||||||
&*self.untracked_resolutions.cstore,
|
|
||||||
&self.untracked_resolutions.source_span,
|
|
||||||
);
|
|
||||||
f(hcx)
|
f(hcx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2428,9 +2413,8 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
st,
|
st,
|
||||||
self.sess,
|
self.sess,
|
||||||
&self.definitions.read(),
|
&self.definitions.read(),
|
||||||
&*self.untracked_resolutions.cstore,
|
|
||||||
// This is only used to create a stable hashing context.
|
// This is only used to create a stable hashing context.
|
||||||
&self.untracked_resolutions.source_span,
|
&self.untracked,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2440,9 +2424,8 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
binder,
|
binder,
|
||||||
self.sess,
|
self.sess,
|
||||||
&self.definitions.read(),
|
&self.definitions.read(),
|
||||||
&*self.untracked_resolutions.cstore,
|
|
||||||
// This is only used to create a stable hashing context.
|
// This is only used to create a stable hashing context.
|
||||||
&self.untracked_resolutions.source_span,
|
&self.untracked,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3124,4 +3107,6 @@ pub fn provide(providers: &mut ty::query::Providers) {
|
||||||
// We want to check if the panic handler was defined in this crate
|
// We want to check if the panic handler was defined in this crate
|
||||||
tcx.lang_items().panic_impl().map_or(false, |did| did.is_local())
|
tcx.lang_items().panic_impl().map_or(false, |did| did.is_local())
|
||||||
};
|
};
|
||||||
|
providers.source_span =
|
||||||
|
|tcx, def_id| tcx.untracked.source_span.get(def_id).copied().unwrap_or(DUMMY_SP);
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ use rustc_index::vec::IndexVec;
|
||||||
use rustc_macros::HashStable;
|
use rustc_macros::HashStable;
|
||||||
use rustc_query_system::ich::StableHashingContext;
|
use rustc_query_system::ich::StableHashingContext;
|
||||||
use rustc_serialize::{Decodable, Encodable};
|
use rustc_serialize::{Decodable, Encodable};
|
||||||
use rustc_session::cstore::CrateStoreDyn;
|
use rustc_session::cstore::Untracked;
|
||||||
use rustc_span::hygiene::MacroKind;
|
use rustc_span::hygiene::MacroKind;
|
||||||
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
||||||
use rustc_span::{ExpnId, Span};
|
use rustc_span::{ExpnId, Span};
|
||||||
|
@ -153,18 +153,16 @@ pub struct ResolverOutputs {
|
||||||
pub definitions: Definitions,
|
pub definitions: Definitions,
|
||||||
pub global_ctxt: ResolverGlobalCtxt,
|
pub global_ctxt: ResolverGlobalCtxt,
|
||||||
pub ast_lowering: ResolverAstLowering,
|
pub ast_lowering: ResolverAstLowering,
|
||||||
|
pub untracked: Untracked,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ResolverGlobalCtxt {
|
pub struct ResolverGlobalCtxt {
|
||||||
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,
|
||||||
/// Item with a given `LocalDefId` was defined during macro expansion with ID `ExpnId`.
|
/// Item with a given `LocalDefId` was defined during macro expansion with ID `ExpnId`.
|
||||||
pub expn_that_defined: FxHashMap<LocalDefId, ExpnId>,
|
pub expn_that_defined: FxHashMap<LocalDefId, ExpnId>,
|
||||||
/// Reference span for definitions.
|
|
||||||
pub source_span: IndexVec<LocalDefId, Span>,
|
|
||||||
pub effective_visibilities: EffectiveVisibilities,
|
pub effective_visibilities: EffectiveVisibilities,
|
||||||
pub extern_crate_map: FxHashMap<LocalDefId, CrateNum>,
|
pub extern_crate_map: FxHashMap<LocalDefId, CrateNum>,
|
||||||
pub maybe_unused_trait_imports: FxIndexSet<LocalDefId>,
|
pub maybe_unused_trait_imports: FxIndexSet<LocalDefId>,
|
||||||
|
|
|
@ -7,8 +7,7 @@ use rustc_data_structures::sync::Lrc;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||||
use rustc_hir::definitions::{DefPathHash, Definitions};
|
use rustc_hir::definitions::{DefPathHash, Definitions};
|
||||||
use rustc_index::vec::IndexVec;
|
use rustc_session::cstore::Untracked;
|
||||||
use rustc_session::cstore::CrateStore;
|
|
||||||
use rustc_session::Session;
|
use rustc_session::Session;
|
||||||
use rustc_span::source_map::SourceMap;
|
use rustc_span::source_map::SourceMap;
|
||||||
use rustc_span::symbol::Symbol;
|
use rustc_span::symbol::Symbol;
|
||||||
|
@ -21,8 +20,7 @@ use rustc_span::{BytePos, CachingSourceMapView, SourceFile, Span, SpanData, DUMM
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct StableHashingContext<'a> {
|
pub struct StableHashingContext<'a> {
|
||||||
definitions: &'a Definitions,
|
definitions: &'a Definitions,
|
||||||
cstore: &'a dyn CrateStore,
|
untracked: &'a Untracked,
|
||||||
source_span: &'a IndexVec<LocalDefId, Span>,
|
|
||||||
// The value of `-Z incremental-ignore-spans`.
|
// The value of `-Z incremental-ignore-spans`.
|
||||||
// This field should only be used by `unstable_opts_incremental_ignore_span`
|
// This field should only be used by `unstable_opts_incremental_ignore_span`
|
||||||
incremental_ignore_spans: bool,
|
incremental_ignore_spans: bool,
|
||||||
|
@ -49,19 +47,13 @@ pub(super) enum BodyResolver<'tcx> {
|
||||||
|
|
||||||
impl<'a> StableHashingContext<'a> {
|
impl<'a> StableHashingContext<'a> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new(
|
pub fn new(sess: &'a Session, definitions: &'a Definitions, untracked: &'a Untracked) -> Self {
|
||||||
sess: &'a Session,
|
|
||||||
definitions: &'a Definitions,
|
|
||||||
cstore: &'a dyn CrateStore,
|
|
||||||
source_span: &'a IndexVec<LocalDefId, Span>,
|
|
||||||
) -> Self {
|
|
||||||
let hash_spans_initial = !sess.opts.unstable_opts.incremental_ignore_spans;
|
let hash_spans_initial = !sess.opts.unstable_opts.incremental_ignore_spans;
|
||||||
|
|
||||||
StableHashingContext {
|
StableHashingContext {
|
||||||
body_resolver: BodyResolver::Forbidden,
|
body_resolver: BodyResolver::Forbidden,
|
||||||
definitions,
|
definitions,
|
||||||
cstore,
|
untracked,
|
||||||
source_span,
|
|
||||||
incremental_ignore_spans: sess.opts.unstable_opts.incremental_ignore_spans,
|
incremental_ignore_spans: sess.opts.unstable_opts.incremental_ignore_spans,
|
||||||
caching_source_map: None,
|
caching_source_map: None,
|
||||||
raw_source_map: sess.source_map(),
|
raw_source_map: sess.source_map(),
|
||||||
|
@ -100,7 +92,7 @@ impl<'a> StableHashingContext<'a> {
|
||||||
if let Some(def_id) = def_id.as_local() {
|
if let Some(def_id) = def_id.as_local() {
|
||||||
self.local_def_path_hash(def_id)
|
self.local_def_path_hash(def_id)
|
||||||
} else {
|
} else {
|
||||||
self.cstore.def_path_hash(def_id)
|
self.untracked.cstore.def_path_hash(def_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +148,7 @@ impl<'a> rustc_span::HashStableContext for StableHashingContext<'a> {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn def_span(&self, def_id: LocalDefId) -> Span {
|
fn def_span(&self, def_id: LocalDefId) -> Span {
|
||||||
*self.source_span.get(def_id).unwrap_or(&DUMMY_SP)
|
*self.untracked.source_span.get(def_id).unwrap_or(&DUMMY_SP)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -153,7 +153,7 @@ impl<'a> Resolver<'a> {
|
||||||
if !candidates.is_empty() {
|
if !candidates.is_empty() {
|
||||||
show_candidates(
|
show_candidates(
|
||||||
&self.session,
|
&self.session,
|
||||||
&self.source_span,
|
&self.untracked.source_span,
|
||||||
&mut err,
|
&mut err,
|
||||||
span,
|
span,
|
||||||
&candidates,
|
&candidates,
|
||||||
|
@ -682,7 +682,7 @@ impl<'a> Resolver<'a> {
|
||||||
}
|
}
|
||||||
show_candidates(
|
show_candidates(
|
||||||
&self.session,
|
&self.session,
|
||||||
&self.source_span,
|
&self.untracked.source_span,
|
||||||
&mut err,
|
&mut err,
|
||||||
Some(span),
|
Some(span),
|
||||||
&import_suggestions,
|
&import_suggestions,
|
||||||
|
@ -1335,7 +1335,7 @@ impl<'a> Resolver<'a> {
|
||||||
self.lookup_import_candidates(ident, Namespace::MacroNS, parent_scope, is_expected);
|
self.lookup_import_candidates(ident, Namespace::MacroNS, parent_scope, is_expected);
|
||||||
show_candidates(
|
show_candidates(
|
||||||
&self.session,
|
&self.session,
|
||||||
&self.source_span,
|
&self.untracked.source_span,
|
||||||
err,
|
err,
|
||||||
None,
|
None,
|
||||||
&import_suggestions,
|
&import_suggestions,
|
||||||
|
|
|
@ -107,7 +107,10 @@ impl<'r, 'a> EffectiveVisibilitiesVisitor<'r, 'a> {
|
||||||
r.effective_visibilities.update_eff_vis(
|
r.effective_visibilities.update_eff_vis(
|
||||||
r.local_def_id(node_id),
|
r.local_def_id(node_id),
|
||||||
eff_vis,
|
eff_vis,
|
||||||
ResolverTree(&r.definitions, &r.cstore),
|
ResolverTree(
|
||||||
|
&r.definitions,
|
||||||
|
&r.untracked.cstore.as_any().downcast_ref().unwrap(),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -541,7 +541,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
|
||||||
if let Some(candidate) = &err.candidate {
|
if let Some(candidate) = &err.candidate {
|
||||||
import_candidates(
|
import_candidates(
|
||||||
self.r.session,
|
self.r.session,
|
||||||
&self.r.source_span,
|
&self.r.untracked.source_span,
|
||||||
&mut diag,
|
&mut diag,
|
||||||
Some(err.span),
|
Some(err.span),
|
||||||
&candidate,
|
&candidate,
|
||||||
|
|
|
@ -46,7 +46,7 @@ use rustc_middle::span_bug;
|
||||||
use rustc_middle::ty::{self, DefIdTree, MainDefinition, RegisteredTools};
|
use rustc_middle::ty::{self, DefIdTree, MainDefinition, RegisteredTools};
|
||||||
use rustc_middle::ty::{ResolverGlobalCtxt, ResolverOutputs};
|
use rustc_middle::ty::{ResolverGlobalCtxt, ResolverOutputs};
|
||||||
use rustc_query_system::ich::StableHashingContext;
|
use rustc_query_system::ich::StableHashingContext;
|
||||||
use rustc_session::cstore::{CrateStore, MetadataLoaderDyn};
|
use rustc_session::cstore::{CrateStore, MetadataLoaderDyn, Untracked};
|
||||||
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};
|
||||||
|
@ -869,8 +869,6 @@ pub struct Resolver<'a> {
|
||||||
definitions: Definitions,
|
definitions: Definitions,
|
||||||
/// Item with a given `LocalDefId` was defined during macro expansion with ID `ExpnId`.
|
/// Item with a given `LocalDefId` was defined during macro expansion with ID `ExpnId`.
|
||||||
expn_that_defined: FxHashMap<LocalDefId, ExpnId>,
|
expn_that_defined: FxHashMap<LocalDefId, ExpnId>,
|
||||||
/// Reference span for definitions.
|
|
||||||
source_span: IndexVec<LocalDefId, Span>,
|
|
||||||
|
|
||||||
graph_root: Module<'a>,
|
graph_root: Module<'a>,
|
||||||
|
|
||||||
|
@ -956,7 +954,7 @@ pub struct Resolver<'a> {
|
||||||
|
|
||||||
local_crate_name: Symbol,
|
local_crate_name: Symbol,
|
||||||
metadata_loader: Box<MetadataLoaderDyn>,
|
metadata_loader: Box<MetadataLoaderDyn>,
|
||||||
cstore: CStore,
|
untracked: Untracked,
|
||||||
used_extern_options: FxHashSet<Symbol>,
|
used_extern_options: FxHashSet<Symbol>,
|
||||||
macro_names: FxHashSet<Ident>,
|
macro_names: FxHashSet<Ident>,
|
||||||
builtin_macros: FxHashMap<Symbol, BuiltinMacroState>,
|
builtin_macros: FxHashMap<Symbol, BuiltinMacroState>,
|
||||||
|
@ -1132,7 +1130,7 @@ impl DefIdTree for ResolverTree<'_> {
|
||||||
impl<'a, 'b> DefIdTree for &'a Resolver<'b> {
|
impl<'a, 'b> DefIdTree for &'a Resolver<'b> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn opt_parent(self, id: DefId) -> Option<DefId> {
|
fn opt_parent(self, id: DefId) -> Option<DefId> {
|
||||||
ResolverTree(&self.definitions, &self.cstore).opt_parent(id)
|
ResolverTree(&self.definitions, self.cstore()).opt_parent(id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1171,7 +1169,7 @@ impl Resolver<'_> {
|
||||||
|
|
||||||
// A relative span's parent must be an absolute span.
|
// A relative span's parent must be an absolute span.
|
||||||
debug_assert_eq!(span.data_untracked().parent, None);
|
debug_assert_eq!(span.data_untracked().parent, None);
|
||||||
let _id = self.source_span.push(span);
|
let _id = self.untracked.source_span.push(span);
|
||||||
debug_assert_eq!(_id, def_id);
|
debug_assert_eq!(_id, def_id);
|
||||||
|
|
||||||
// Some things for which we allocate `LocalDefId`s don't correspond to
|
// Some things for which we allocate `LocalDefId`s don't correspond to
|
||||||
|
@ -1263,7 +1261,6 @@ impl<'a> Resolver<'a> {
|
||||||
|
|
||||||
definitions,
|
definitions,
|
||||||
expn_that_defined: Default::default(),
|
expn_that_defined: Default::default(),
|
||||||
source_span,
|
|
||||||
|
|
||||||
// The outermost module has def ID 0; this is not reflected in the
|
// The outermost module has def ID 0; this is not reflected in the
|
||||||
// AST.
|
// AST.
|
||||||
|
@ -1317,7 +1314,7 @@ impl<'a> Resolver<'a> {
|
||||||
metadata_loader,
|
metadata_loader,
|
||||||
local_crate_name: crate_name,
|
local_crate_name: crate_name,
|
||||||
used_extern_options: Default::default(),
|
used_extern_options: Default::default(),
|
||||||
cstore: CStore::new(session),
|
untracked: Untracked { cstore: Box::new(CStore::new(session)), source_span },
|
||||||
macro_names: FxHashSet::default(),
|
macro_names: FxHashSet::default(),
|
||||||
builtin_macros: Default::default(),
|
builtin_macros: Default::default(),
|
||||||
builtin_macro_kinds: Default::default(),
|
builtin_macro_kinds: Default::default(),
|
||||||
|
@ -1409,8 +1406,6 @@ impl<'a> Resolver<'a> {
|
||||||
pub fn into_outputs(self) -> ResolverOutputs {
|
pub fn into_outputs(self) -> 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.cstore);
|
|
||||||
let source_span = self.source_span;
|
|
||||||
let expn_that_defined = self.expn_that_defined;
|
let expn_that_defined = self.expn_that_defined;
|
||||||
let visibilities = self.visibilities;
|
let visibilities = self.visibilities;
|
||||||
let has_pub_restricted = self.has_pub_restricted;
|
let has_pub_restricted = self.has_pub_restricted;
|
||||||
|
@ -1422,9 +1417,8 @@ 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 effective_visibilities = self.effective_visibilities;
|
let effective_visibilities = self.effective_visibilities;
|
||||||
|
let untracked = self.untracked;
|
||||||
let global_ctxt = ResolverGlobalCtxt {
|
let global_ctxt = ResolverGlobalCtxt {
|
||||||
cstore,
|
|
||||||
source_span,
|
|
||||||
expn_that_defined,
|
expn_that_defined,
|
||||||
visibilities,
|
visibilities,
|
||||||
has_pub_restricted,
|
has_pub_restricted,
|
||||||
|
@ -1459,16 +1453,15 @@ impl<'a> Resolver<'a> {
|
||||||
builtin_macro_kinds: self.builtin_macro_kinds,
|
builtin_macro_kinds: self.builtin_macro_kinds,
|
||||||
lifetime_elision_allowed: self.lifetime_elision_allowed,
|
lifetime_elision_allowed: self.lifetime_elision_allowed,
|
||||||
};
|
};
|
||||||
ResolverOutputs { definitions, global_ctxt, ast_lowering }
|
ResolverOutputs { definitions, global_ctxt, ast_lowering, untracked }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn clone_outputs(&self) -> ResolverOutputs {
|
pub fn clone_outputs(&self) -> 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.clone();
|
let definitions = self.definitions.clone();
|
||||||
let cstore = Box::new(self.cstore().clone());
|
let cstore = Box::new(self.cstore().clone());
|
||||||
|
let untracked = Untracked { cstore, source_span: self.untracked.source_span.clone() };
|
||||||
let global_ctxt = ResolverGlobalCtxt {
|
let global_ctxt = ResolverGlobalCtxt {
|
||||||
cstore,
|
|
||||||
source_span: self.source_span.clone(),
|
|
||||||
expn_that_defined: self.expn_that_defined.clone(),
|
expn_that_defined: self.expn_that_defined.clone(),
|
||||||
visibilities: self.visibilities.clone(),
|
visibilities: self.visibilities.clone(),
|
||||||
has_pub_restricted: self.has_pub_restricted,
|
has_pub_restricted: self.has_pub_restricted,
|
||||||
|
@ -1503,11 +1496,11 @@ impl<'a> Resolver<'a> {
|
||||||
builtin_macro_kinds: self.builtin_macro_kinds.clone(),
|
builtin_macro_kinds: self.builtin_macro_kinds.clone(),
|
||||||
lifetime_elision_allowed: self.lifetime_elision_allowed.clone(),
|
lifetime_elision_allowed: self.lifetime_elision_allowed.clone(),
|
||||||
};
|
};
|
||||||
ResolverOutputs { definitions, global_ctxt, ast_lowering }
|
ResolverOutputs { definitions, global_ctxt, ast_lowering, untracked }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_stable_hashing_context(&self) -> StableHashingContext<'_> {
|
fn create_stable_hashing_context(&self) -> StableHashingContext<'_> {
|
||||||
StableHashingContext::new(self.session, &self.definitions, &self.cstore, &self.source_span)
|
StableHashingContext::new(self.session, &self.definitions, &self.untracked)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn crate_loader(&mut self) -> CrateLoader<'_> {
|
pub fn crate_loader(&mut self) -> CrateLoader<'_> {
|
||||||
|
@ -1515,14 +1508,14 @@ impl<'a> Resolver<'a> {
|
||||||
&self.session,
|
&self.session,
|
||||||
&*self.metadata_loader,
|
&*self.metadata_loader,
|
||||||
self.local_crate_name,
|
self.local_crate_name,
|
||||||
&mut self.cstore,
|
&mut *self.untracked.cstore.untracked_as_any().downcast_mut().unwrap(),
|
||||||
&self.definitions,
|
&self.definitions,
|
||||||
&mut self.used_extern_options,
|
&mut self.used_extern_options,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn cstore(&self) -> &CStore {
|
pub fn cstore(&self) -> &CStore {
|
||||||
&self.cstore
|
self.untracked.cstore.as_any().downcast_ref().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dummy_ext(&self, macro_kind: MacroKind) -> Lrc<SyntaxExtension> {
|
fn dummy_ext(&self, macro_kind: MacroKind) -> Lrc<SyntaxExtension> {
|
||||||
|
@ -1958,7 +1951,7 @@ impl<'a> Resolver<'a> {
|
||||||
/// Retrieves the span of the given `DefId` if `DefId` is in the local crate.
|
/// Retrieves the span of the given `DefId` if `DefId` is in the local crate.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn opt_span(&self, def_id: DefId) -> Option<Span> {
|
pub fn opt_span(&self, def_id: DefId) -> Option<Span> {
|
||||||
def_id.as_local().map(|def_id| self.source_span[def_id])
|
def_id.as_local().map(|def_id| self.untracked.source_span[def_id])
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieves the name of the given `DefId`.
|
/// Retrieves the name of the given `DefId`.
|
||||||
|
|
|
@ -455,7 +455,7 @@ impl<'a> ResolverExpand for Resolver<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_proc_macro_quoted_span(&self, krate: CrateNum, id: usize) -> Span {
|
fn get_proc_macro_quoted_span(&self, krate: CrateNum, id: usize) -> Span {
|
||||||
self.cstore.get_proc_macro_quoted_span_untracked(krate, id, self.session)
|
self.cstore().get_proc_macro_quoted_span_untracked(krate, id, self.session)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn declare_proc_macro(&mut self, id: NodeId) {
|
fn declare_proc_macro(&mut self, id: NodeId) {
|
||||||
|
|
|
@ -13,6 +13,7 @@ rustc_hir = { path = "../rustc_hir" }
|
||||||
rustc_target = { path = "../rustc_target" }
|
rustc_target = { path = "../rustc_target" }
|
||||||
rustc_serialize = { path = "../rustc_serialize" }
|
rustc_serialize = { path = "../rustc_serialize" }
|
||||||
rustc_data_structures = { path = "../rustc_data_structures" }
|
rustc_data_structures = { path = "../rustc_data_structures" }
|
||||||
|
rustc_index = { path = "../rustc_index" }
|
||||||
rustc_span = { path = "../rustc_span" }
|
rustc_span = { path = "../rustc_span" }
|
||||||
rustc_fs_util = { path = "../rustc_fs_util" }
|
rustc_fs_util = { path = "../rustc_fs_util" }
|
||||||
rustc_ast = { path = "../rustc_ast" }
|
rustc_ast = { path = "../rustc_ast" }
|
||||||
|
|
|
@ -7,8 +7,9 @@ use crate::utils::NativeLibKind;
|
||||||
use crate::Session;
|
use crate::Session;
|
||||||
use rustc_ast as ast;
|
use rustc_ast as ast;
|
||||||
use rustc_data_structures::sync::{self, MetadataRef};
|
use rustc_data_structures::sync::{self, MetadataRef};
|
||||||
use rustc_hir::def_id::{CrateNum, DefId, StableCrateId, LOCAL_CRATE};
|
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, StableCrateId, LOCAL_CRATE};
|
||||||
use rustc_hir::definitions::{DefKey, DefPath, DefPathHash};
|
use rustc_hir::definitions::{DefKey, DefPath, DefPathHash};
|
||||||
|
use rustc_index::vec::IndexVec;
|
||||||
use rustc_span::hygiene::{ExpnHash, ExpnId};
|
use rustc_span::hygiene::{ExpnHash, ExpnId};
|
||||||
use rustc_span::symbol::Symbol;
|
use rustc_span::symbol::Symbol;
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
|
@ -217,6 +218,7 @@ pub type MetadataLoaderDyn = dyn MetadataLoader + Sync;
|
||||||
/// during resolve)
|
/// during resolve)
|
||||||
pub trait CrateStore: std::fmt::Debug {
|
pub trait CrateStore: std::fmt::Debug {
|
||||||
fn as_any(&self) -> &dyn Any;
|
fn as_any(&self) -> &dyn Any;
|
||||||
|
fn untracked_as_any(&mut self) -> &mut dyn Any;
|
||||||
|
|
||||||
// Foreign definitions.
|
// Foreign definitions.
|
||||||
// This information is safe to access, since it's hashed as part of the DefPathHash, which incr.
|
// This information is safe to access, since it's hashed as part of the DefPathHash, which incr.
|
||||||
|
@ -249,3 +251,10 @@ pub trait CrateStore: std::fmt::Debug {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type CrateStoreDyn = dyn CrateStore + sync::Sync;
|
pub type CrateStoreDyn = dyn CrateStore + sync::Sync;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct Untracked {
|
||||||
|
pub cstore: Box<CrateStoreDyn>,
|
||||||
|
/// Reference span for definitions.
|
||||||
|
pub source_span: IndexVec<LocalDefId, Span>,
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue