1
Fork 0

Revert "Reduce the amount of untracked state in TyCtxt"

This commit is contained in:
Camille Gillot 2021-06-01 09:05:22 +02:00 committed by GitHub
parent c9c1f8be3f
commit 0f0f3138cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
49 changed files with 255 additions and 234 deletions

View file

@ -51,12 +51,6 @@ pub struct CStore {
unused_externs: Vec<Symbol>,
}
impl std::fmt::Debug for CStore {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("CStore").finish_non_exhaustive()
}
}
pub struct CrateLoader<'a> {
// Immutable configuration.
sess: &'a Session,

View file

@ -31,5 +31,3 @@ mod rmeta;
pub mod creader;
pub mod dynamic_lib;
pub mod locator;
pub use rmeta::METADATA_HEADER;

View file

@ -1,7 +1,7 @@
use crate::creader::{CStore, LoadedMacro};
use crate::foreign_modules;
use crate::native_libs;
use crate::rmeta::encoder;
use crate::rmeta::{self, encoder};
use rustc_ast as ast;
use rustc_ast::expand::allocator::AllocatorKind;
@ -187,8 +187,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
foreign_modules => { cdata.get_foreign_modules(tcx) }
crate_hash => { cdata.root.hash }
crate_host_hash => { cdata.host_hash }
crate_name => { cdata.root.name }
is_private_dep => { cdata.private_dep }
original_crate_name => { cdata.root.name }
extra_filename => { cdata.root.extra_filename.clone() }
@ -205,6 +204,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
let r = *cdata.dep_kind.lock();
r
}
crate_name => { cdata.root.name }
item_children => {
let mut result = SmallVec::<[_; 8]>::new();
cdata.each_child_of_item(def_id.index, |child| result.push(child), tcx.sess);
@ -477,6 +477,10 @@ impl CrateStore for CStore {
self.get_crate_data(cnum).root.name
}
fn crate_is_private_dep_untracked(&self, cnum: CrateNum) -> bool {
self.get_crate_data(cnum).private_dep
}
fn stable_crate_id_untracked(&self, cnum: CrateNum) -> StableCrateId {
self.get_crate_data(cnum).root.stable_crate_id
}
@ -524,6 +528,10 @@ impl CrateStore for CStore {
encoder::encode_metadata(tcx)
}
fn metadata_encoding_version(&self) -> &[u8] {
rmeta::METADATA_HEADER
}
fn allocator_kind(&self) -> Option<AllocatorKind> {
self.allocator_kind()
}

View file

@ -445,7 +445,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
}
fn encode_def_path_table(&mut self) {
let table = self.tcx.resolutions(()).definitions.def_path_table();
let table = self.tcx.hir().definitions().def_path_table();
if self.is_proc_macro {
for def_index in std::iter::once(CRATE_DEF_INDEX)
.chain(self.tcx.hir().krate().proc_macros.iter().map(|p| p.owner.local_def_index))
@ -1062,7 +1062,7 @@ impl EncodeContext<'a, 'tcx> {
let data = ModData {
reexports,
expansion: tcx.resolutions(()).definitions.expansion_that_defined(local_def_id),
expansion: tcx.hir().definitions().expansion_that_defined(local_def_id),
};
record!(self.tables.kind[def_id] <- EntryKind::Mod(self.lazy(data)));
@ -1673,7 +1673,7 @@ impl EncodeContext<'a, 'tcx> {
.iter()
.map(|&cnum| {
let dep = CrateDep {
name: self.tcx.crate_name(cnum),
name: self.tcx.original_crate_name(cnum),
hash: self.tcx.crate_hash(cnum),
host_hash: self.tcx.crate_host_hash(cnum),
kind: self.tcx.dep_kind(cnum),
@ -1754,7 +1754,7 @@ impl EncodeContext<'a, 'tcx> {
.map(|(trait_def_id, mut impls)| {
// Bring everything into deterministic order for hashing
impls.sort_by_cached_key(|&(index, _)| {
tcx.hir().def_path_hash(LocalDefId { local_def_index: index })
tcx.hir().definitions().def_path_hash(LocalDefId { local_def_index: index })
});
TraitImpls {

View file

@ -51,7 +51,7 @@ const METADATA_VERSION: u8 = 5;
/// This header is followed by the position of the `CrateRoot`,
/// which is encoded as a 32-bit big-endian unsigned integer,
/// and further followed by the rustc version string.
pub const METADATA_HEADER: &[u8; 8] = &[b'r', b'u', b's', b't', 0, 0, 0, METADATA_VERSION];
crate const METADATA_HEADER: &[u8; 8] = &[b'r', b'u', b's', b't', 0, 0, 0, METADATA_VERSION];
/// Additional metadata for a `Lazy<T>` where `T` may not be `Sized`,
/// e.g. for `Lazy<[T]>`, this is the length (count of `T` values).