@@ -15,7 +15,7 @@ use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
1515use rustc_data_structures:: jobserver:: { self , Client } ;
1616use rustc_data_structures:: profiling:: { SelfProfiler , SelfProfilerRef } ;
1717use rustc_data_structures:: sync:: {
18- AtomicU64 , DynSend , DynSync , Lock , Lrc , OneThread , Ordering :: SeqCst ,
18+ AtomicU64 , DynSend , DynSync , Lock , Lrc , MappedReadGuard , Ordering :: SeqCst , ReadGuard , RwLock ,
1919} ;
2020use rustc_errors:: annotate_snippet_emitter_writer:: AnnotateSnippetEmitterWriter ;
2121use rustc_errors:: emitter:: { DynEmitter , EmitterWriter , HumanReadableErrorType } ;
@@ -38,7 +38,6 @@ use rustc_target::spec::{
3838} ;
3939
4040use std:: any:: Any ;
41- use std:: cell:: { self , RefCell } ;
4241use std:: env;
4342use std:: fmt;
4443use std:: ops:: { Div , Mul } ;
@@ -152,7 +151,7 @@ pub struct Session {
152151 /// Input, input file path and output file path to this compilation process.
153152 pub io : CompilerIO ,
154153
155- incr_comp_session : OneThread < RefCell < IncrCompSession > > ,
154+ incr_comp_session : RwLock < IncrCompSession > ,
156155
157156 /// Used by `-Z self-profile`.
158157 pub prof : SelfProfilerRef ,
@@ -848,9 +847,9 @@ impl Session {
848847 * incr_comp_session = IncrCompSession :: InvalidBecauseOfErrors { session_directory } ;
849848 }
850849
851- pub fn incr_comp_session_dir ( & self ) -> cell :: Ref < ' _ , PathBuf > {
850+ pub fn incr_comp_session_dir ( & self ) -> MappedReadGuard < ' _ , PathBuf > {
852851 let incr_comp_session = self . incr_comp_session . borrow ( ) ;
853- cell :: Ref :: map ( incr_comp_session, |incr_comp_session| match * incr_comp_session {
852+ ReadGuard :: map ( incr_comp_session, |incr_comp_session| match * incr_comp_session {
854853 IncrCompSession :: NotInitialized => panic ! (
855854 "trying to get session directory from `IncrCompSession`: {:?}" ,
856855 * incr_comp_session,
@@ -863,7 +862,7 @@ impl Session {
863862 } )
864863 }
865864
866- pub fn incr_comp_session_dir_opt ( & self ) -> Option < cell :: Ref < ' _ , PathBuf > > {
865+ pub fn incr_comp_session_dir_opt ( & self ) -> Option < MappedReadGuard < ' _ , PathBuf > > {
867866 self . opts . incremental . as_ref ( ) . map ( |_| self . incr_comp_session_dir ( ) )
868867 }
869868
@@ -1494,7 +1493,7 @@ pub fn build_session(
14941493 parse_sess,
14951494 sysroot,
14961495 io,
1497- incr_comp_session : OneThread :: new ( RefCell :: new ( IncrCompSession :: NotInitialized ) ) ,
1496+ incr_comp_session : RwLock :: new ( IncrCompSession :: NotInitialized ) ,
14981497 prof,
14991498 code_stats : Default :: default ( ) ,
15001499 optimization_fuel,
0 commit comments