@@ -17,7 +17,8 @@ use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
1717use rustc_data_structures:: jobserver:: { self , Client } ;
1818use rustc_data_structures:: profiling:: { duration_to_secs_str, SelfProfiler , SelfProfilerRef } ;
1919use rustc_data_structures:: sync:: {
20- AtomicU64 , AtomicUsize , Lock , Lrc , OneThread , Ordering , Ordering :: SeqCst ,
20+ AtomicU64 , AtomicUsize , Lock , Lrc , MappedReadGuard , Ordering , Ordering :: SeqCst , ReadGuard ,
21+ RwLock ,
2122} ;
2223use rustc_errors:: annotate_snippet_emitter_writer:: AnnotateSnippetEmitterWriter ;
2324use rustc_errors:: emitter:: { DynEmitter , EmitterWriter , HumanReadableErrorType } ;
@@ -39,7 +40,6 @@ use rustc_target::spec::{
3940 DebuginfoKind , SanitizerSet , SplitDebuginfo , StackProtector , Target , TargetTriple , TlsModel ,
4041} ;
4142
42- use std:: cell:: { self , RefCell } ;
4343use std:: env;
4444use std:: fmt;
4545use std:: ops:: { Div , Mul } ;
@@ -152,7 +152,7 @@ pub struct Session {
152152 /// Input, input file path and output file path to this compilation process.
153153 pub io : CompilerIO ,
154154
155- incr_comp_session : OneThread < RefCell < IncrCompSession > > ,
155+ incr_comp_session : RwLock < IncrCompSession > ,
156156 /// Used for incremental compilation tests. Will only be populated if
157157 /// `-Zquery-dep-graph` is specified.
158158 pub cgu_reuse_tracker : CguReuseTracker ,
@@ -853,9 +853,9 @@ impl Session {
853853 * incr_comp_session = IncrCompSession :: InvalidBecauseOfErrors { session_directory } ;
854854 }
855855
856- pub fn incr_comp_session_dir ( & self ) -> cell :: Ref < ' _ , PathBuf > {
856+ pub fn incr_comp_session_dir ( & self ) -> MappedReadGuard < ' _ , PathBuf > {
857857 let incr_comp_session = self . incr_comp_session . borrow ( ) ;
858- cell :: Ref :: map ( incr_comp_session, |incr_comp_session| match * incr_comp_session {
858+ ReadGuard :: map ( incr_comp_session, |incr_comp_session| match * incr_comp_session {
859859 IncrCompSession :: NotInitialized => panic ! (
860860 "trying to get session directory from `IncrCompSession`: {:?}" ,
861861 * incr_comp_session,
@@ -868,7 +868,7 @@ impl Session {
868868 } )
869869 }
870870
871- pub fn incr_comp_session_dir_opt ( & self ) -> Option < cell :: Ref < ' _ , PathBuf > > {
871+ pub fn incr_comp_session_dir_opt ( & self ) -> Option < MappedReadGuard < ' _ , PathBuf > > {
872872 self . opts . incremental . as_ref ( ) . map ( |_| self . incr_comp_session_dir ( ) )
873873 }
874874
@@ -1460,7 +1460,7 @@ pub fn build_session(
14601460 parse_sess,
14611461 sysroot,
14621462 io,
1463- incr_comp_session : OneThread :: new ( RefCell :: new ( IncrCompSession :: NotInitialized ) ) ,
1463+ incr_comp_session : RwLock :: new ( IncrCompSession :: NotInitialized ) ,
14641464 cgu_reuse_tracker,
14651465 prof,
14661466 perf_stats : PerfStats {
0 commit comments