|
1 | 1 | //! Type context book-keeping.
|
2 | 2 |
|
3 | 3 | use crate::arena::Arena;
|
4 |
| -use crate::dep_graph::{self, DepConstructor, DepGraph}; |
| 4 | +use crate::dep_graph::{self, DepGraph, DepKind, DepNode, DepNodeExt}; |
5 | 5 | use crate::hir::exports::ExportMap;
|
6 | 6 | use crate::ich::{NodeIdHashingMode, StableHashingContext};
|
7 | 7 | use crate::infer::canonical::{Canonical, CanonicalVarInfo, CanonicalVarInfos};
|
@@ -34,12 +34,12 @@ use rustc_data_structures::stable_hasher::{
|
34 | 34 | };
|
35 | 35 | use rustc_data_structures::steal::Steal;
|
36 | 36 | use rustc_data_structures::sync::{self, Lock, Lrc, WorkerLocal};
|
37 |
| -use rustc_data_structures::unhash::UnhashMap; |
38 | 37 | use rustc_errors::ErrorReported;
|
39 | 38 | use rustc_hir as hir;
|
40 | 39 | use rustc_hir::def::{DefKind, Res};
|
41 |
| -use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, LOCAL_CRATE}; |
42 |
| -use rustc_hir::definitions::{DefPathHash, Definitions}; |
| 40 | +use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId}; |
| 41 | +use rustc_hir::def_id::{CRATE_DEF_INDEX, LOCAL_CRATE}; |
| 42 | +use rustc_hir::definitions::Definitions; |
43 | 43 | use rustc_hir::intravisit::Visitor;
|
44 | 44 | use rustc_hir::lang_items::LangItem;
|
45 | 45 | use rustc_hir::{
|
@@ -945,10 +945,6 @@ pub struct GlobalCtxt<'tcx> {
|
945 | 945 | pub(crate) untracked_crate: &'tcx hir::Crate<'tcx>,
|
946 | 946 | pub(crate) definitions: &'tcx Definitions,
|
947 | 947 |
|
948 |
| - /// A map from `DefPathHash` -> `DefId`. Includes `DefId`s from the local crate |
949 |
| - /// as well as all upstream crates. Only populated in incremental mode. |
950 |
| - pub def_path_hash_to_def_id: Option<UnhashMap<DefPathHash, DefId>>, |
951 |
| - |
952 | 948 | pub queries: query::Queries<'tcx>,
|
953 | 949 |
|
954 | 950 | maybe_unused_trait_imports: FxHashSet<LocalDefId>,
|
@@ -1113,21 +1109,6 @@ impl<'tcx> TyCtxt<'tcx> {
|
1113 | 1109 | let mut providers = IndexVec::from_elem_n(extern_providers, max_cnum + 1);
|
1114 | 1110 | providers[LOCAL_CRATE] = local_providers;
|
1115 | 1111 |
|
1116 |
| - let def_path_hash_to_def_id = if s.opts.build_dep_graph() { |
1117 |
| - let capacity = definitions.def_path_table().num_def_ids() |
1118 |
| - + crates.iter().map(|cnum| cstore.num_def_ids(*cnum)).sum::<usize>(); |
1119 |
| - let mut map = UnhashMap::with_capacity_and_hasher(capacity, Default::default()); |
1120 |
| - |
1121 |
| - map.extend(definitions.def_path_table().all_def_path_hashes_and_def_ids(LOCAL_CRATE)); |
1122 |
| - for cnum in &crates { |
1123 |
| - map.extend(cstore.all_def_path_hashes_and_def_ids(*cnum).into_iter()); |
1124 |
| - } |
1125 |
| - |
1126 |
| - Some(map) |
1127 |
| - } else { |
1128 |
| - None |
1129 |
| - }; |
1130 |
| - |
1131 | 1112 | let mut trait_map: FxHashMap<_, FxHashMap<_, _>> = FxHashMap::default();
|
1132 | 1113 | for (hir_id, v) in krate.trait_map.iter() {
|
1133 | 1114 | let map = trait_map.entry(hir_id.owner).or_default();
|
@@ -1155,7 +1136,6 @@ impl<'tcx> TyCtxt<'tcx> {
|
1155 | 1136 | extern_prelude: resolutions.extern_prelude,
|
1156 | 1137 | untracked_crate: krate,
|
1157 | 1138 | definitions,
|
1158 |
| - def_path_hash_to_def_id, |
1159 | 1139 | queries: query::Queries::new(providers, extern_providers, on_disk_query_result_cache),
|
1160 | 1140 | ty_rcache: Default::default(),
|
1161 | 1141 | pred_rcache: Default::default(),
|
@@ -1329,7 +1309,8 @@ impl<'tcx> TyCtxt<'tcx> {
|
1329 | 1309 | // We cannot use the query versions of crates() and crate_hash(), since
|
1330 | 1310 | // those would need the DepNodes that we are allocating here.
|
1331 | 1311 | for cnum in self.cstore.crates_untracked() {
|
1332 |
| - let dep_node = DepConstructor::CrateMetadata(self, cnum); |
| 1312 | + let def_path_hash = self.def_path_hash(DefId { krate: cnum, index: CRATE_DEF_INDEX }); |
| 1313 | + let dep_node = DepNode::from_def_path_hash(def_path_hash, DepKind::CrateMetadata); |
1333 | 1314 | let crate_hash = self.cstore.crate_hash_untracked(cnum);
|
1334 | 1315 | self.dep_graph.with_task(
|
1335 | 1316 | dep_node,
|
|
0 commit comments