@@ -23,7 +23,7 @@ use rustc_session::Session;
2323use rustc_span:: hygiene:: {
2424 ExpnId , HygieneDecodeContext , HygieneEncodeContext , SyntaxContext , SyntaxContextData ,
2525} ;
26- use rustc_span:: source_map:: { SourceMap , Spanned } ;
26+ use rustc_span:: source_map:: Spanned ;
2727use rustc_span:: {
2828 BytePos , CachingSourceMapView , ExpnData , ExpnHash , Pos , RelativeBytePos , SourceFile , Span ,
2929 SpanDecoder , SpanEncoder , StableSourceFileId , Symbol ,
@@ -49,15 +49,14 @@ const SYMBOL_PREINTERNED: u8 = 2;
4949/// previous compilation session. This data will eventually include the results
5050/// of a few selected queries (like `typeck` and `mir_optimized`) and
5151/// any side effects that have been emitted during a query.
52- pub struct OnDiskCache < ' sess > {
52+ pub struct OnDiskCache {
5353 // The complete cache data in serialized form.
5454 serialized_data : RwLock < Option < Mmap > > ,
5555
5656 // Collects all `QuerySideEffects` created during the current compilation
5757 // session.
5858 current_side_effects : Lock < FxHashMap < DepNodeIndex , QuerySideEffects > > ,
5959
60- source_map : & ' sess SourceMap ,
6160 file_index_to_stable_id : FxHashMap < SourceFileIndex , EncodedSourceFileId > ,
6261
6362 // Caches that are populated lazily during decoding.
@@ -151,12 +150,12 @@ impl EncodedSourceFileId {
151150 }
152151}
153152
154- impl < ' sess > OnDiskCache < ' sess > {
153+ impl OnDiskCache {
155154 /// Creates a new `OnDiskCache` instance from the serialized data in `data`.
156155 ///
157156 /// The serialized cache has some basic integrity checks, if those checks indicate that the
158157 /// 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 , ( ) > {
160159 assert ! ( sess. opts. incremental. is_some( ) ) ;
161160
162161 let mut decoder = MemDecoder :: new ( & data, start_pos) ?;
@@ -175,7 +174,6 @@ impl<'sess> OnDiskCache<'sess> {
175174 serialized_data : RwLock :: new ( Some ( data) ) ,
176175 file_index_to_stable_id : footer. file_index_to_stable_id ,
177176 file_index_to_file : Default :: default ( ) ,
178- source_map : sess. source_map ( ) ,
179177 current_side_effects : Default :: default ( ) ,
180178 query_result_index : footer. query_result_index . into_iter ( ) . collect ( ) ,
181179 prev_side_effects_index : footer. side_effects_index . into_iter ( ) . collect ( ) ,
@@ -187,12 +185,11 @@ impl<'sess> OnDiskCache<'sess> {
187185 } )
188186 }
189187
190- pub fn new_empty ( source_map : & ' sess SourceMap ) -> Self {
188+ pub fn new_empty ( ) -> Self {
191189 Self {
192190 serialized_data : RwLock :: new ( None ) ,
193191 file_index_to_stable_id : Default :: default ( ) ,
194192 file_index_to_file : Default :: default ( ) ,
195- source_map,
196193 current_side_effects : Default :: default ( ) ,
197194 query_result_index : Default :: default ( ) ,
198195 prev_side_effects_index : Default :: default ( ) ,
@@ -423,7 +420,7 @@ impl<'sess> OnDiskCache<'sess> {
423420 }
424421
425422 fn with_decoder < ' a , ' tcx , T , F : for < ' s > FnOnce ( & mut CacheDecoder < ' s , ' tcx > ) -> T > (
426- & ' sess self ,
423+ & self ,
427424 tcx : TyCtxt < ' tcx > ,
428425 pos : AbsoluteBytePos ,
429426 f : F ,
@@ -436,7 +433,6 @@ impl<'sess> OnDiskCache<'sess> {
436433 tcx,
437434 opaque : MemDecoder :: new ( serialized_data. as_deref ( ) . unwrap_or ( & [ ] ) , pos. to_usize ( ) )
438435 . unwrap ( ) ,
439- source_map : self . source_map ,
440436 file_index_to_file : & self . file_index_to_file ,
441437 file_index_to_stable_id : & self . file_index_to_stable_id ,
442438 alloc_decoding_session : self . alloc_decoding_state . new_decoding_session ( ) ,
@@ -457,7 +453,6 @@ impl<'sess> OnDiskCache<'sess> {
457453pub struct CacheDecoder < ' a , ' tcx > {
458454 tcx : TyCtxt < ' tcx > ,
459455 opaque : MemDecoder < ' a > ,
460- source_map : & ' a SourceMap ,
461456 file_index_to_file : & ' a Lock < FxHashMap < SourceFileIndex , Lrc < SourceFile > > > ,
462457 file_index_to_stable_id : & ' a FxHashMap < SourceFileIndex , EncodedSourceFileId > ,
463458 alloc_decoding_session : AllocDecodingSession < ' a > ,
@@ -470,8 +465,7 @@ pub struct CacheDecoder<'a, 'tcx> {
470465impl < ' a , ' tcx > CacheDecoder < ' a , ' tcx > {
471466 #[ inline]
472467 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 ;
475469
476470 Lrc :: clone ( file_index_to_file. borrow_mut ( ) . entry ( index) . or_insert_with ( || {
477471 let source_file_id = & file_index_to_stable_id[ & index] ;
@@ -490,7 +484,8 @@ impl<'a, 'tcx> CacheDecoder<'a, 'tcx> {
490484 self . tcx . import_source_files ( source_file_cnum) ;
491485 }
492486
493- source_map
487+ tcx. sess
488+ . source_map ( )
494489 . source_file_by_stable_id ( source_file_id. stable_source_file_id )
495490 . expect ( "failed to lookup `SourceFile` in new context" )
496491 } ) )
0 commit comments