Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 1202fce

Browse files
committed
Remove definitions field that is only needed for one method
1 parent 4953d70 commit 1202fce

File tree

3 files changed

+8
-14
lines changed

3 files changed

+8
-14
lines changed

compiler/rustc_metadata/src/creader.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_ast::expand::allocator::AllocatorKind;
88
use rustc_ast::{self as ast, *};
99
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
1010
use rustc_data_structures::svh::Svh;
11-
use rustc_data_structures::sync::{MappedReadGuard, ReadGuard};
11+
use rustc_data_structures::sync::MappedReadGuard;
1212
use rustc_expand::base::SyntaxExtension;
1313
use rustc_hir::def_id::{CrateNum, LocalDefId, StableCrateId, LOCAL_CRATE};
1414
use rustc_hir::definitions::Definitions;
@@ -64,7 +64,6 @@ pub struct CrateLoader<'a> {
6464
// Immutable configuration.
6565
sess: &'a Session,
6666
metadata_loader: &'a MetadataLoaderDyn,
67-
definitions: ReadGuard<'a, Definitions>,
6867
local_crate_name: Symbol,
6968
// Mutable output.
7069
cstore: &'a mut CStore,
@@ -261,17 +260,9 @@ impl<'a> CrateLoader<'a> {
261260
metadata_loader: &'a MetadataLoaderDyn,
262261
local_crate_name: Symbol,
263262
cstore: &'a mut CStore,
264-
definitions: ReadGuard<'a, Definitions>,
265263
used_extern_options: &'a mut FxHashSet<Symbol>,
266264
) -> Self {
267-
CrateLoader {
268-
sess,
269-
metadata_loader,
270-
local_crate_name,
271-
cstore,
272-
used_extern_options,
273-
definitions,
274-
}
265+
CrateLoader { sess, metadata_loader, local_crate_name, cstore, used_extern_options }
275266
}
276267
pub fn cstore(&self) -> &CStore {
277268
&self.cstore
@@ -989,6 +980,7 @@ impl<'a> CrateLoader<'a> {
989980
&mut self,
990981
item: &ast::Item,
991982
def_id: LocalDefId,
983+
definitions: &Definitions,
992984
) -> Option<CrateNum> {
993985
match item.kind {
994986
ast::ItemKind::ExternCrate(orig_name) => {
@@ -1011,7 +1003,7 @@ impl<'a> CrateLoader<'a> {
10111003

10121004
let cnum = self.resolve_crate(name, item.span, dep_kind)?;
10131005

1014-
let path_len = self.definitions.def_path(def_id).data.len();
1006+
let path_len = definitions.def_path(def_id).data.len();
10151007
self.update_extern_crate(
10161008
cnum,
10171009
ExternCrate {

compiler/rustc_resolve/src/build_reduced_graph.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,10 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
855855
} else if orig_name == Some(kw::SelfLower) {
856856
Some(self.r.graph_root)
857857
} else {
858-
let crate_id = self.r.crate_loader(|c| c.process_extern_crate(item, local_def_id));
858+
let tcx = self.r.tcx;
859+
let crate_id = self.r.crate_loader(|c| {
860+
c.process_extern_crate(item, local_def_id, &tcx.definitions_untracked())
861+
});
859862
crate_id.map(|crate_id| {
860863
self.r.extern_crate_map.insert(local_def_id, crate_id);
861864
self.r.expect_module(crate_id.as_def_id())

compiler/rustc_resolve/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1470,7 +1470,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
14701470
&*self.metadata_loader,
14711471
self.local_crate_name,
14721472
&mut *self.tcx.untracked().cstore.write().untracked_as_any().downcast_mut().unwrap(),
1473-
self.tcx.definitions_untracked(),
14741473
&mut self.used_extern_options,
14751474
))
14761475
}

0 commit comments

Comments
 (0)