@@ -14,7 +14,9 @@ use rustc_data_structures::flock;
1414use rustc_data_structures:: fx:: { FxHashMap , FxIndexSet } ;
1515use rustc_data_structures:: jobserver:: { self , Client } ;
1616use rustc_data_structures:: profiling:: { SelfProfiler , SelfProfilerRef } ;
17- use rustc_data_structures:: sync:: { AtomicU64 , DynSend , DynSync , Lock , Lrc , OneThread } ;
17+ use rustc_data_structures:: sync:: {
18+ AtomicU64 , DynSend , DynSync , Lock , Lrc , MappedReadGuard , ReadGuard , RwLock ,
19+ } ;
1820use rustc_errors:: annotate_snippet_emitter_writer:: AnnotateSnippetEmitter ;
1921use rustc_errors:: emitter:: { DynEmitter , HumanEmitter , HumanReadableErrorType } ;
2022use rustc_errors:: json:: JsonEmitter ;
@@ -35,7 +37,6 @@ use rustc_target::spec::{
3537} ;
3638
3739use std:: any:: Any ;
38- use std:: cell:: { self , RefCell } ;
3940use std:: env;
4041use std:: fmt;
4142use std:: ops:: { Div , Mul } ;
@@ -149,7 +150,7 @@ pub struct Session {
149150 /// Input, input file path and output file path to this compilation process.
150151 pub io : CompilerIO ,
151152
152- incr_comp_session : OneThread < RefCell < IncrCompSession > > ,
153+ incr_comp_session : RwLock < IncrCompSession > ,
153154
154155 /// Used by `-Z self-profile`.
155156 pub prof : SelfProfilerRef ,
@@ -533,9 +534,9 @@ impl Session {
533534 * incr_comp_session = IncrCompSession :: InvalidBecauseOfErrors { session_directory } ;
534535 }
535536
536- pub fn incr_comp_session_dir ( & self ) -> cell :: Ref < ' _ , PathBuf > {
537+ pub fn incr_comp_session_dir ( & self ) -> MappedReadGuard < ' _ , PathBuf > {
537538 let incr_comp_session = self . incr_comp_session . borrow ( ) ;
538- cell :: Ref :: map ( incr_comp_session, |incr_comp_session| match * incr_comp_session {
539+ ReadGuard :: map ( incr_comp_session, |incr_comp_session| match * incr_comp_session {
539540 IncrCompSession :: NotInitialized => panic ! (
540541 "trying to get session directory from `IncrCompSession`: {:?}" ,
541542 * incr_comp_session,
@@ -548,7 +549,7 @@ impl Session {
548549 } )
549550 }
550551
551- pub fn incr_comp_session_dir_opt ( & self ) -> Option < cell :: Ref < ' _ , PathBuf > > {
552+ pub fn incr_comp_session_dir_opt ( & self ) -> Option < MappedReadGuard < ' _ , PathBuf > > {
552553 self . opts . incremental . as_ref ( ) . map ( |_| self . incr_comp_session_dir ( ) )
553554 }
554555
@@ -1176,7 +1177,7 @@ pub fn build_session(
11761177 parse_sess,
11771178 sysroot,
11781179 io,
1179- incr_comp_session : OneThread :: new ( RefCell :: new ( IncrCompSession :: NotInitialized ) ) ,
1180+ incr_comp_session : RwLock :: new ( IncrCompSession :: NotInitialized ) ,
11801181 prof,
11811182 code_stats : Default :: default ( ) ,
11821183 optimization_fuel,
0 commit comments