Remove definitions field that is only needed for one method

This commit is contained in:
Oli Scherer 2022-12-13 10:01:53 +00:00
parent 4953d70e2f
commit 1202fce40e
3 changed files with 8 additions and 14 deletions

View File

@ -8,7 +8,7 @@ use rustc_ast::expand::allocator::AllocatorKind;
use rustc_ast::{self as ast, *}; use rustc_ast::{self as ast, *};
use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::svh::Svh; use rustc_data_structures::svh::Svh;
use rustc_data_structures::sync::{MappedReadGuard, ReadGuard}; use rustc_data_structures::sync::MappedReadGuard;
use rustc_expand::base::SyntaxExtension; use rustc_expand::base::SyntaxExtension;
use rustc_hir::def_id::{CrateNum, LocalDefId, StableCrateId, LOCAL_CRATE}; use rustc_hir::def_id::{CrateNum, LocalDefId, StableCrateId, LOCAL_CRATE};
use rustc_hir::definitions::Definitions; use rustc_hir::definitions::Definitions;
@ -64,7 +64,6 @@ pub struct CrateLoader<'a> {
// Immutable configuration. // Immutable configuration.
sess: &'a Session, sess: &'a Session,
metadata_loader: &'a MetadataLoaderDyn, metadata_loader: &'a MetadataLoaderDyn,
definitions: ReadGuard<'a, Definitions>,
local_crate_name: Symbol, local_crate_name: Symbol,
// Mutable output. // Mutable output.
cstore: &'a mut CStore, cstore: &'a mut CStore,
@ -261,17 +260,9 @@ impl<'a> CrateLoader<'a> {
metadata_loader: &'a MetadataLoaderDyn, metadata_loader: &'a MetadataLoaderDyn,
local_crate_name: Symbol, local_crate_name: Symbol,
cstore: &'a mut CStore, cstore: &'a mut CStore,
definitions: ReadGuard<'a, Definitions>,
used_extern_options: &'a mut FxHashSet<Symbol>, used_extern_options: &'a mut FxHashSet<Symbol>,
) -> Self { ) -> Self {
CrateLoader { CrateLoader { sess, metadata_loader, local_crate_name, cstore, used_extern_options }
sess,
metadata_loader,
local_crate_name,
cstore,
used_extern_options,
definitions,
}
} }
pub fn cstore(&self) -> &CStore { pub fn cstore(&self) -> &CStore {
&self.cstore &self.cstore
@ -989,6 +980,7 @@ impl<'a> CrateLoader<'a> {
&mut self, &mut self,
item: &ast::Item, item: &ast::Item,
def_id: LocalDefId, def_id: LocalDefId,
definitions: &Definitions,
) -> Option<CrateNum> { ) -> Option<CrateNum> {
match item.kind { match item.kind {
ast::ItemKind::ExternCrate(orig_name) => { ast::ItemKind::ExternCrate(orig_name) => {
@ -1011,7 +1003,7 @@ impl<'a> CrateLoader<'a> {
let cnum = self.resolve_crate(name, item.span, dep_kind)?; let cnum = self.resolve_crate(name, item.span, dep_kind)?;
let path_len = self.definitions.def_path(def_id).data.len(); let path_len = definitions.def_path(def_id).data.len();
self.update_extern_crate( self.update_extern_crate(
cnum, cnum,
ExternCrate { ExternCrate {

View File

@ -855,7 +855,10 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
} else if orig_name == Some(kw::SelfLower) { } else if orig_name == Some(kw::SelfLower) {
Some(self.r.graph_root) Some(self.r.graph_root)
} else { } else {
let crate_id = self.r.crate_loader(|c| c.process_extern_crate(item, local_def_id)); let tcx = self.r.tcx;
let crate_id = self.r.crate_loader(|c| {
c.process_extern_crate(item, local_def_id, &tcx.definitions_untracked())
});
crate_id.map(|crate_id| { crate_id.map(|crate_id| {
self.r.extern_crate_map.insert(local_def_id, crate_id); self.r.extern_crate_map.insert(local_def_id, crate_id);
self.r.expect_module(crate_id.as_def_id()) self.r.expect_module(crate_id.as_def_id())

View File

@ -1470,7 +1470,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
&*self.metadata_loader, &*self.metadata_loader,
self.local_crate_name, self.local_crate_name,
&mut *self.tcx.untracked().cstore.write().untracked_as_any().downcast_mut().unwrap(), &mut *self.tcx.untracked().cstore.write().untracked_as_any().downcast_mut().unwrap(),
self.tcx.definitions_untracked(),
&mut self.used_extern_options, &mut self.used_extern_options,
)) ))
} }