@@ -23,7 +23,7 @@ use rustc_session::Session;
23
23
use rustc_span:: hygiene:: {
24
24
ExpnId , HygieneDecodeContext , HygieneEncodeContext , SyntaxContext , SyntaxContextData ,
25
25
} ;
26
- use rustc_span:: source_map:: { SourceMap , Spanned } ;
26
+ use rustc_span:: source_map:: Spanned ;
27
27
use rustc_span:: {
28
28
BytePos , CachingSourceMapView , ExpnData , ExpnHash , Pos , RelativeBytePos , SourceFile , Span ,
29
29
SpanDecoder , SpanEncoder , StableSourceFileId , Symbol ,
@@ -49,15 +49,14 @@ const SYMBOL_PREINTERNED: u8 = 2;
49
49
/// previous compilation session. This data will eventually include the results
50
50
/// of a few selected queries (like `typeck` and `mir_optimized`) and
51
51
/// any side effects that have been emitted during a query.
52
- pub struct OnDiskCache < ' sess > {
52
+ pub struct OnDiskCache {
53
53
// The complete cache data in serialized form.
54
54
serialized_data : RwLock < Option < Mmap > > ,
55
55
56
56
// Collects all `QuerySideEffects` created during the current compilation
57
57
// session.
58
58
current_side_effects : Lock < FxHashMap < DepNodeIndex , QuerySideEffects > > ,
59
59
60
- source_map : & ' sess SourceMap ,
61
60
file_index_to_stable_id : FxHashMap < SourceFileIndex , EncodedSourceFileId > ,
62
61
63
62
// Caches that are populated lazily during decoding.
@@ -151,12 +150,12 @@ impl EncodedSourceFileId {
151
150
}
152
151
}
153
152
154
- impl < ' sess > OnDiskCache < ' sess > {
153
+ impl OnDiskCache {
155
154
/// Creates a new `OnDiskCache` instance from the serialized data in `data`.
156
155
///
157
156
/// The serialized cache has some basic integrity checks, if those checks indicate that the
158
157
/// on-disk data is corrupt, an error is returned.
159
- pub fn new ( sess : & ' sess Session , data : Mmap , start_pos : usize ) -> Result < Self , ( ) > {
158
+ pub fn new ( sess : & Session , data : Mmap , start_pos : usize ) -> Result < Self , ( ) > {
160
159
assert ! ( sess. opts. incremental. is_some( ) ) ;
161
160
162
161
let mut decoder = MemDecoder :: new ( & data, start_pos) ?;
@@ -175,7 +174,6 @@ impl<'sess> OnDiskCache<'sess> {
175
174
serialized_data : RwLock :: new ( Some ( data) ) ,
176
175
file_index_to_stable_id : footer. file_index_to_stable_id ,
177
176
file_index_to_file : Default :: default ( ) ,
178
- source_map : sess. source_map ( ) ,
179
177
current_side_effects : Default :: default ( ) ,
180
178
query_result_index : footer. query_result_index . into_iter ( ) . collect ( ) ,
181
179
prev_side_effects_index : footer. side_effects_index . into_iter ( ) . collect ( ) ,
@@ -187,12 +185,11 @@ impl<'sess> OnDiskCache<'sess> {
187
185
} )
188
186
}
189
187
190
- pub fn new_empty ( source_map : & ' sess SourceMap ) -> Self {
188
+ pub fn new_empty ( ) -> Self {
191
189
Self {
192
190
serialized_data : RwLock :: new ( None ) ,
193
191
file_index_to_stable_id : Default :: default ( ) ,
194
192
file_index_to_file : Default :: default ( ) ,
195
- source_map,
196
193
current_side_effects : Default :: default ( ) ,
197
194
query_result_index : Default :: default ( ) ,
198
195
prev_side_effects_index : Default :: default ( ) ,
@@ -423,7 +420,7 @@ impl<'sess> OnDiskCache<'sess> {
423
420
}
424
421
425
422
fn with_decoder < ' a , ' tcx , T , F : for < ' s > FnOnce ( & mut CacheDecoder < ' s , ' tcx > ) -> T > (
426
- & ' sess self ,
423
+ & self ,
427
424
tcx : TyCtxt < ' tcx > ,
428
425
pos : AbsoluteBytePos ,
429
426
f : F ,
@@ -436,7 +433,6 @@ impl<'sess> OnDiskCache<'sess> {
436
433
tcx,
437
434
opaque : MemDecoder :: new ( serialized_data. as_deref ( ) . unwrap_or ( & [ ] ) , pos. to_usize ( ) )
438
435
. unwrap ( ) ,
439
- source_map : self . source_map ,
440
436
file_index_to_file : & self . file_index_to_file ,
441
437
file_index_to_stable_id : & self . file_index_to_stable_id ,
442
438
alloc_decoding_session : self . alloc_decoding_state . new_decoding_session ( ) ,
@@ -457,7 +453,6 @@ impl<'sess> OnDiskCache<'sess> {
457
453
pub struct CacheDecoder < ' a , ' tcx > {
458
454
tcx : TyCtxt < ' tcx > ,
459
455
opaque : MemDecoder < ' a > ,
460
- source_map : & ' a SourceMap ,
461
456
file_index_to_file : & ' a Lock < FxHashMap < SourceFileIndex , Lrc < SourceFile > > > ,
462
457
file_index_to_stable_id : & ' a FxHashMap < SourceFileIndex , EncodedSourceFileId > ,
463
458
alloc_decoding_session : AllocDecodingSession < ' a > ,
@@ -470,8 +465,7 @@ pub struct CacheDecoder<'a, 'tcx> {
470
465
impl < ' a , ' tcx > CacheDecoder < ' a , ' tcx > {
471
466
#[ inline]
472
467
fn file_index_to_file ( & self , index : SourceFileIndex ) -> Lrc < SourceFile > {
473
- let CacheDecoder { tcx, file_index_to_file, file_index_to_stable_id, source_map, .. } =
474
- * self ;
468
+ let CacheDecoder { tcx, file_index_to_file, file_index_to_stable_id, .. } = * self ;
475
469
476
470
Lrc :: clone ( file_index_to_file. borrow_mut ( ) . entry ( index) . or_insert_with ( || {
477
471
let source_file_id = & file_index_to_stable_id[ & index] ;
@@ -490,7 +484,8 @@ impl<'a, 'tcx> CacheDecoder<'a, 'tcx> {
490
484
self . tcx . import_source_files ( source_file_cnum) ;
491
485
}
492
486
493
- source_map
487
+ tcx. sess
488
+ . source_map ( )
494
489
. source_file_by_stable_id ( source_file_id. stable_source_file_id )
495
490
. expect ( "failed to lookup `SourceFile` in new context" )
496
491
} ) )
0 commit comments