Skip to content

Commit 0f0f313

Browse files
authored
Revert "Reduce the amount of untracked state in TyCtxt"
1 parent c9c1f8b commit 0f0f313

File tree

49 files changed

+255
-234
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+255
-234
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3677,7 +3677,6 @@ dependencies = [
36773677
"rustc_incremental",
36783678
"rustc_index",
36793679
"rustc_llvm",
3680-
"rustc_metadata",
36813680
"rustc_middle",
36823681
"rustc_serialize",
36833682
"rustc_session",

compiler/rustc_ast/src/expand/allocator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use rustc_span::symbol::{sym, Symbol};
22

3-
#[derive(Clone, Debug, Copy, HashStable_Generic)]
3+
#[derive(Clone, Copy)]
44
pub enum AllocatorKind {
55
Global,
66
Default,

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ use rustc_ast::walk_list;
4343
use rustc_ast::{self as ast, *};
4444
use rustc_ast_pretty::pprust;
4545
use rustc_data_structures::captures::Captures;
46-
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
46+
use rustc_data_structures::fx::FxHashSet;
4747
use rustc_data_structures::sync::Lrc;
4848
use rustc_errors::{struct_span_err, Applicability};
4949
use rustc_hir as hir;
@@ -198,7 +198,7 @@ pub trait ResolverAstLowering {
198198

199199
fn next_node_id(&mut self) -> NodeId;
200200

201-
fn take_trait_map(&mut self) -> NodeMap<Vec<hir::TraitCandidate>>;
201+
fn trait_map(&self) -> &NodeMap<Vec<hir::TraitCandidate>>;
202202

203203
fn opt_local_def_id(&self, node: NodeId) -> Option<LocalDefId>;
204204

@@ -501,13 +501,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
501501
let proc_macros =
502502
c.proc_macros.iter().map(|id| self.node_id_to_hir_id[*id].unwrap()).collect();
503503

504-
let mut trait_map: FxHashMap<_, FxHashMap<_, _>> = FxHashMap::default();
505-
for (k, v) in self.resolver.take_trait_map().into_iter() {
506-
if let Some(Some(hir_id)) = self.node_id_to_hir_id.get(k) {
507-
let map = trait_map.entry(hir_id.owner).or_default();
508-
map.insert(hir_id.local_id, v.into_boxed_slice());
509-
}
510-
}
504+
let trait_map = self
505+
.resolver
506+
.trait_map()
507+
.iter()
508+
.filter_map(|(&k, v)| {
509+
self.node_id_to_hir_id.get(k).and_then(|id| id.as_ref()).map(|id| (*id, v.clone()))
510+
})
511+
.collect();
511512

512513
let mut def_id_to_hir_id = IndexVec::default();
513514

compiler/rustc_codegen_cranelift/src/allocator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub(crate) fn codegen(
1919
});
2020
if any_dynamic_crate {
2121
false
22-
} else if let Some(kind) = tcx.allocator_kind(()) {
22+
} else if let Some(kind) = tcx.allocator_kind() {
2323
codegen_inner(module, unwind_context, kind);
2424
true
2525
} else {

compiler/rustc_codegen_cranelift/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ extern crate rustc_fs_util;
1414
extern crate rustc_hir;
1515
extern crate rustc_incremental;
1616
extern crate rustc_index;
17-
extern crate rustc_metadata;
1817
extern crate rustc_session;
1918
extern crate rustc_span;
2019
extern crate rustc_target;

compiler/rustc_codegen_cranelift/src/metadata.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub(crate) fn write_metadata<O: WriteMetadata>(tcx: TyCtxt<'_>, object: &mut O)
1010
use std::io::Write;
1111

1212
let metadata = tcx.encode_metadata();
13-
let mut compressed = rustc_metadata::METADATA_HEADER.to_vec();
13+
let mut compressed = tcx.metadata_encoding_version();
1414
FrameEncoder::new(&mut compressed).write_all(&metadata.raw_data).unwrap();
1515

1616
object.add_rustc_section(

compiler/rustc_codegen_llvm/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ rustc_hir = { path = "../rustc_hir" }
2727
rustc_incremental = { path = "../rustc_incremental" }
2828
rustc_index = { path = "../rustc_index" }
2929
rustc_llvm = { path = "../rustc_llvm" }
30-
rustc_metadata = { path = "../rustc_metadata" }
3130
rustc_session = { path = "../rustc_session" }
3231
rustc_serialize = { path = "../rustc_serialize" }
3332
rustc_target = { path = "../rustc_target" }

compiler/rustc_codegen_llvm/src/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub fn write_compressed_metadata<'tcx>(
6363
let section_name = if tcx.sess.target.is_like_osx { "__DATA,.rustc" } else { ".rustc" };
6464

6565
let (metadata_llcx, metadata_llmod) = (&*llvm_module.llcx, llvm_module.llmod());
66-
let mut compressed = rustc_metadata::METADATA_HEADER.to_vec();
66+
let mut compressed = tcx.metadata_encoding_version();
6767
FrameEncoder::new(&mut compressed).write_all(&metadata.raw_data).unwrap();
6868

6969
let llmeta = common::bytes_in_context(metadata_llcx, &compressed);

compiler/rustc_codegen_ssa/src/back/symbol_export.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ fn exported_symbols_provider_local(
180180
symbols.push((exported_symbol, SymbolExportLevel::C));
181181
}
182182

183-
if tcx.allocator_kind(()).is_some() {
183+
if tcx.allocator_kind().is_some() {
184184
for method in ALLOCATOR_METHODS {
185185
let symbol_name = format!("__rust_{}", method.name);
186186
let exported_symbol = ExportedSymbol::NoDefId(SymbolName::new(tcx, &symbol_name));

compiler/rustc_codegen_ssa/src/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
517517
});
518518
let allocator_module = if any_dynamic_crate {
519519
None
520-
} else if let Some(kind) = tcx.allocator_kind(()) {
520+
} else if let Some(kind) = tcx.allocator_kind() {
521521
let llmod_id =
522522
cgu_name_builder.build_cgu_name(LOCAL_CRATE, &["crate"], Some("allocator")).to_string();
523523
let mut modules = backend.new_metadata(tcx, &llmod_id);

0 commit comments

Comments
 (0)