@@ -10,7 +10,7 @@ use rustc_data_structures::thin_vec::ThinVec;
1010use rustc_data_structures:: unhash:: UnhashMap ;
1111use rustc_errors:: Diagnostic ;
1212use rustc_hir:: def_id:: { CrateNum , DefId , DefIndex , LocalDefId , LOCAL_CRATE } ;
13- use rustc_hir:: definitions:: { DefPathHash , DefPathTable } ;
13+ use rustc_hir:: definitions:: DefPathHash ;
1414use rustc_index:: vec:: { Idx , IndexVec } ;
1515use rustc_query_system:: dep_graph:: DepContext ;
1616use rustc_query_system:: query:: QueryContext ;
@@ -27,7 +27,6 @@ use rustc_span::source_map::{SourceMap, StableSourceFileId};
2727use rustc_span:: CachingSourceMapView ;
2828use rustc_span:: { BytePos , ExpnData , SourceFile , Span , DUMMY_SP } ;
2929use std:: collections:: hash_map:: Entry ;
30- use std:: iter:: FromIterator ;
3130use std:: mem;
3231
3332const TAG_FILE_FOOTER : u128 = 0xC0FFEE_C0FFEE_C0FFEE_C0FFEE_C0FFEE ;
@@ -103,12 +102,6 @@ pub struct OnDiskCache<'sess> {
103102 // during the next compilation session.
104103 latest_foreign_def_path_hashes : Lock < UnhashMap < DefPathHash , RawDefId > > ,
105104
106- // Maps `DefPathHashes` to their corresponding `LocalDefId`s for all
107- // local items in the current compilation session. This is only populated
108- // when we are in incremental mode and have loaded a pre-existing cache
109- // from disk, since this map is only used when deserializing a `DefPathHash`
110- // from the incremental cache.
111- local_def_path_hash_to_def_id : UnhashMap < DefPathHash , LocalDefId > ,
112105 // Caches all lookups of `DefPathHashes`, both for local and foreign
113106 // definitions. A definition from the previous compilation session
114107 // may no longer exist in the current compilation session, so
@@ -168,12 +161,7 @@ crate struct RawDefId {
168161
169162impl < ' sess > OnDiskCache < ' sess > {
170163 /// Creates a new `OnDiskCache` instance from the serialized data in `data`.
171- pub fn new (
172- sess : & ' sess Session ,
173- data : Vec < u8 > ,
174- start_pos : usize ,
175- def_path_table : & DefPathTable ,
176- ) -> Self {
164+ pub fn new ( sess : & ' sess Session , data : Vec < u8 > , start_pos : usize ) -> Self {
177165 debug_assert ! ( sess. opts. incremental. is_some( ) ) ;
178166
179167 // Wrap in a scope so we can borrow `data`.
@@ -210,11 +198,6 @@ impl<'sess> OnDiskCache<'sess> {
210198 hygiene_context : Default :: default ( ) ,
211199 foreign_def_path_hashes : footer. foreign_def_path_hashes ,
212200 latest_foreign_def_path_hashes : Default :: default ( ) ,
213- local_def_path_hash_to_def_id : UnhashMap :: from_iter (
214- def_path_table
215- . all_def_path_hashes_and_def_ids ( LOCAL_CRATE )
216- . map ( |( hash, def_id) | ( hash, def_id. as_local ( ) . unwrap ( ) ) ) ,
217- ) ,
218201 def_path_hash_to_def_id_cache : Default :: default ( ) ,
219202 }
220203 }
@@ -236,7 +219,6 @@ impl<'sess> OnDiskCache<'sess> {
236219 hygiene_context : Default :: default ( ) ,
237220 foreign_def_path_hashes : Default :: default ( ) ,
238221 latest_foreign_def_path_hashes : Default :: default ( ) ,
239- local_def_path_hash_to_def_id : Default :: default ( ) ,
240222 def_path_hash_to_def_id_cache : Default :: default ( ) ,
241223 }
242224 }
@@ -616,7 +598,7 @@ impl<'sess> OnDiskCache<'sess> {
616598 debug ! ( "def_path_hash_to_def_id({:?})" , hash) ;
617599 // Check if the `DefPathHash` corresponds to a definition in the current
618600 // crate
619- if let Some ( def_id) = self . local_def_path_hash_to_def_id . get ( & hash) . cloned ( ) {
601+ if let Some ( def_id) = tcx . definitions . local_def_path_hash_to_def_id ( hash) {
620602 let def_id = def_id. to_def_id ( ) ;
621603 e. insert ( Some ( def_id) ) ;
622604 return Some ( def_id) ;
0 commit comments