@@ -6,7 +6,7 @@ use rustc_data_structures::unhash::UnhashMap;
6
6
use rustc_hir:: def_id:: { CrateNum , DefId , DefIndex , LocalDefId , StableCrateId , LOCAL_CRATE } ;
7
7
use rustc_hir:: definitions:: DefPathHash ;
8
8
use rustc_index:: vec:: { Idx , IndexVec } ;
9
- use rustc_middle:: dep_graph:: { DepNode , DepNodeIndex , SerializedDepNodeIndex } ;
9
+ use rustc_middle:: dep_graph:: { DepNodeIndex , SerializedDepNodeIndex } ;
10
10
use rustc_middle:: mir:: interpret:: { AllocDecodingSession , AllocDecodingState } ;
11
11
use rustc_middle:: mir:: { self , interpret} ;
12
12
use rustc_middle:: thir;
@@ -86,27 +86,9 @@ pub struct OnDiskCache<'sess> {
86
86
expn_data : UnhashMap < ExpnHash , AbsoluteBytePos > ,
87
87
// Additional information used when decoding hygiene data.
88
88
hygiene_context : HygieneDecodeContext ,
89
- // Maps `DefPathHash`es to their `RawDefId`s from the *previous*
90
- // compilation session. This is used as an initial 'guess' when
91
- // we try to map a `DefPathHash` to its `DefId` in the current compilation
92
- // session.
93
- foreign_def_path_hashes : UnhashMap < DefPathHash , RawDefId > ,
89
+ // FIXME(mw): Update this comment:
94
90
// Likewise for ExpnId.
95
91
foreign_expn_data : UnhashMap < ExpnHash , u32 > ,
96
-
97
- // The *next* compilation sessison's `foreign_def_path_hashes` - at
98
- // the end of our current compilation session, this will get written
99
- // out to the `foreign_def_path_hashes` field of the `Footer`, which
100
- // will become `foreign_def_path_hashes` of the next compilation session.
101
- // This stores any `DefPathHash` that we may need to map to a `DefId`
102
- // during the next compilation session.
103
- latest_foreign_def_path_hashes : Lock < UnhashMap < DefPathHash , RawDefId > > ,
104
-
105
- // Caches all lookups of `DefPathHashes`, both for local and foreign
106
- // definitions. A definition from the previous compilation session
107
- // may no longer exist in the current compilation session, so
108
- // we use `Option<DefId>` so that we can cache a lookup failure.
109
- def_path_hash_to_def_id_cache : Lock < UnhashMap < DefPathHash , Option < DefId > > > ,
110
92
}
111
93
112
94
// This type is used only for serialization and deserialization.
@@ -121,7 +103,6 @@ struct Footer {
121
103
syntax_contexts : FxHashMap < u32 , AbsoluteBytePos > ,
122
104
// See `OnDiskCache.expn_data`
123
105
expn_data : UnhashMap < ExpnHash , AbsoluteBytePos > ,
124
- foreign_def_path_hashes : UnhashMap < DefPathHash , RawDefId > ,
125
106
foreign_expn_data : UnhashMap < ExpnHash , u32 > ,
126
107
}
127
108
@@ -144,19 +125,6 @@ impl AbsoluteBytePos {
144
125
}
145
126
}
146
127
147
- /// Represents a potentially invalid `DefId`. This is used during incremental
148
- /// compilation to represent a `DefId` from the *previous* compilation session,
149
- /// which may no longer be valid. This is used to help map a `DefPathHash`
150
- /// to a `DefId` in the current compilation session.
151
- #[ derive( Encodable , Decodable , Copy , Clone , Debug ) ]
152
- crate struct RawDefId {
153
- // We deliberately do not use `CrateNum` and `DefIndex`
154
- // here, since a crate/index from the previous compilation
155
- // session may no longer exist.
156
- pub krate : u32 ,
157
- pub index : u32 ,
158
- }
159
-
160
128
/// An `EncodedSourceFileId` is the same as a `StableSourceFileId` except that
161
129
/// the source crate is represented as a [StableCrateId] instead of as a
162
130
/// `CrateNum`. This way `EncodedSourceFileId` can be encoded and decoded
@@ -220,9 +188,6 @@ impl<'sess> rustc_middle::ty::OnDiskCache<'sess> for OnDiskCache<'sess> {
220
188
expn_data : footer. expn_data ,
221
189
foreign_expn_data : footer. foreign_expn_data ,
222
190
hygiene_context : Default :: default ( ) ,
223
- foreign_def_path_hashes : footer. foreign_def_path_hashes ,
224
- latest_foreign_def_path_hashes : Default :: default ( ) ,
225
- def_path_hash_to_def_id_cache : Default :: default ( ) ,
226
191
}
227
192
}
228
193
@@ -241,9 +206,6 @@ impl<'sess> rustc_middle::ty::OnDiskCache<'sess> for OnDiskCache<'sess> {
241
206
expn_data : UnhashMap :: default ( ) ,
242
207
foreign_expn_data : UnhashMap :: default ( ) ,
243
208
hygiene_context : Default :: default ( ) ,
244
- foreign_def_path_hashes : Default :: default ( ) ,
245
- latest_foreign_def_path_hashes : Default :: default ( ) ,
246
- def_path_hash_to_def_id_cache : Default :: default ( ) ,
247
209
}
248
210
}
249
211
@@ -253,13 +215,6 @@ impl<'sess> rustc_middle::ty::OnDiskCache<'sess> for OnDiskCache<'sess> {
253
215
/// In order to serialize the new on-disk cache, the former on-disk cache file needs to be
254
216
/// deleted, hence we won't be able to refer to its memmapped data.
255
217
fn drop_serialized_data ( & self , tcx : TyCtxt < ' tcx > ) {
256
- // Register any dep nodes that we reused from the previous session,
257
- // but didn't `DepNode::construct` in this session. This ensures
258
- // that their `DefPathHash` to `RawDefId` mappings are registered
259
- // in 'latest_foreign_def_path_hashes' if necessary, since that
260
- // normally happens in `DepNode::construct`.
261
- tcx. dep_graph . register_reused_dep_nodes ( tcx) ;
262
-
263
218
// Load everything into memory so we can write it out to the on-disk
264
219
// cache. The vast majority of cacheable query results should already
265
220
// be in memory, so this should be a cheap operation.
@@ -293,7 +248,6 @@ impl<'sess> rustc_middle::ty::OnDiskCache<'sess> for OnDiskCache<'sess> {
293
248
( file_to_file_index, file_index_to_stable_id)
294
249
} ;
295
250
296
- let latest_foreign_def_path_hashes = self . latest_foreign_def_path_hashes . lock ( ) . clone ( ) ;
297
251
let hygiene_encode_context = HygieneEncodeContext :: default ( ) ;
298
252
299
253
let mut encoder = CacheEncoder {
@@ -305,7 +259,6 @@ impl<'sess> rustc_middle::ty::OnDiskCache<'sess> for OnDiskCache<'sess> {
305
259
source_map : CachingSourceMapView :: new ( tcx. sess . source_map ( ) ) ,
306
260
file_to_file_index,
307
261
hygiene_context : & hygiene_encode_context,
308
- latest_foreign_def_path_hashes,
309
262
} ;
310
263
311
264
// Encode query results.
@@ -382,9 +335,6 @@ impl<'sess> rustc_middle::ty::OnDiskCache<'sess> for OnDiskCache<'sess> {
382
335
} ,
383
336
) ?;
384
337
385
- let foreign_def_path_hashes =
386
- std:: mem:: take ( & mut encoder. latest_foreign_def_path_hashes ) ;
387
-
388
338
// `Encode the file footer.
389
339
let footer_pos = encoder. position ( ) as u64 ;
390
340
encoder. encode_tagged (
@@ -397,7 +347,6 @@ impl<'sess> rustc_middle::ty::OnDiskCache<'sess> for OnDiskCache<'sess> {
397
347
syntax_contexts,
398
348
expn_data,
399
349
foreign_expn_data,
400
- foreign_def_path_hashes,
401
350
} ,
402
351
) ?;
403
352
@@ -460,17 +409,6 @@ impl<'sess> OnDiskCache<'sess> {
460
409
debug_assert ! ( prev. is_none( ) ) ;
461
410
}
462
411
463
- fn get_raw_def_id ( & self , hash : & DefPathHash ) -> Option < RawDefId > {
464
- self . foreign_def_path_hashes . get ( hash) . copied ( )
465
- }
466
-
467
- fn try_remap_cnum ( & self , tcx : TyCtxt < ' _ > , stable_crate_id : StableCrateId ) -> Option < CrateNum > {
468
- let cnum_map = self . cnum_map . get_or_init ( || Self :: compute_cnum_map ( tcx) ) ;
469
- debug ! ( "try_remap_cnum({:?}): cnum_map={:?}" , stable_crate_id, cnum_map) ;
470
-
471
- cnum_map. get ( & stable_crate_id) . copied ( )
472
- }
473
-
474
412
/// Returns the cached query result if there is something in the cache for
475
413
/// the given `SerializedDepNodeIndex`; otherwise returns `None`.
476
414
pub fn try_load_query_result < ' tcx , T > (
@@ -911,7 +849,6 @@ pub struct CacheEncoder<'a, 'tcx, E: OpaqueEncoder> {
911
849
source_map : CachingSourceMapView < ' tcx > ,
912
850
file_to_file_index : FxHashMap < * const SourceFile , SourceFileIndex > ,
913
851
hygiene_context : & ' a HygieneEncodeContext ,
914
- latest_foreign_def_path_hashes : UnhashMap < DefPathHash , RawDefId > ,
915
852
}
916
853
917
854
impl < ' a , ' tcx , E > CacheEncoder < ' a , ' tcx , E >
@@ -1044,17 +981,7 @@ where
1044
981
E : ' a + OpaqueEncoder ,
1045
982
{
1046
983
fn encode ( & self , s : & mut CacheEncoder < ' a , ' tcx , E > ) -> Result < ( ) , E :: Error > {
1047
- let def_path_hash = s. tcx . def_path_hash ( * self ) ;
1048
- // Store additional information when we encode a foreign `DefId`,
1049
- // so that we can map its `DefPathHash` back to a `DefId` in the next
1050
- // compilation session.
1051
- if !self . is_local ( ) {
1052
- s. latest_foreign_def_path_hashes . insert (
1053
- def_path_hash,
1054
- RawDefId { krate : self . krate . as_u32 ( ) , index : self . index . as_u32 ( ) } ,
1055
- ) ;
1056
- }
1057
- def_path_hash. encode ( s)
984
+ s. tcx . def_path_hash ( * self ) . encode ( s)
1058
985
}
1059
986
}
1060
987
0 commit comments