@@ -15,7 +15,7 @@ use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
15
15
use rustc_data_structures:: jobserver:: { self , Client } ;
16
16
use rustc_data_structures:: profiling:: { SelfProfiler , SelfProfilerRef } ;
17
17
use rustc_data_structures:: sync:: {
18
- AtomicU64 , DynSend , DynSync , Lock , Lrc , OneThread , Ordering :: SeqCst ,
18
+ AtomicU64 , DynSend , DynSync , Lock , Lrc , MappedReadGuard , Ordering :: SeqCst , ReadGuard , RwLock ,
19
19
} ;
20
20
use rustc_errors:: annotate_snippet_emitter_writer:: AnnotateSnippetEmitterWriter ;
21
21
use rustc_errors:: emitter:: { DynEmitter , EmitterWriter , HumanReadableErrorType } ;
@@ -38,7 +38,6 @@ use rustc_target::spec::{
38
38
} ;
39
39
40
40
use std:: any:: Any ;
41
- use std:: cell:: { self , RefCell } ;
42
41
use std:: env;
43
42
use std:: fmt;
44
43
use std:: ops:: { Div , Mul } ;
@@ -152,7 +151,7 @@ pub struct Session {
152
151
/// Input, input file path and output file path to this compilation process.
153
152
pub io : CompilerIO ,
154
153
155
- incr_comp_session : OneThread < RefCell < IncrCompSession > > ,
154
+ incr_comp_session : RwLock < IncrCompSession > ,
156
155
157
156
/// Used by `-Z self-profile`.
158
157
pub prof : SelfProfilerRef ,
@@ -848,9 +847,9 @@ impl Session {
848
847
* incr_comp_session = IncrCompSession :: InvalidBecauseOfErrors { session_directory } ;
849
848
}
850
849
851
- pub fn incr_comp_session_dir ( & self ) -> cell :: Ref < ' _ , PathBuf > {
850
+ pub fn incr_comp_session_dir ( & self ) -> MappedReadGuard < ' _ , PathBuf > {
852
851
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 {
854
853
IncrCompSession :: NotInitialized => panic ! (
855
854
"trying to get session directory from `IncrCompSession`: {:?}" ,
856
855
* incr_comp_session,
@@ -863,7 +862,7 @@ impl Session {
863
862
} )
864
863
}
865
864
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 > > {
867
866
self . opts . incremental . as_ref ( ) . map ( |_| self . incr_comp_session_dir ( ) )
868
867
}
869
868
@@ -1494,7 +1493,7 @@ pub fn build_session(
1494
1493
parse_sess,
1495
1494
sysroot,
1496
1495
io,
1497
- incr_comp_session : OneThread :: new ( RefCell :: new ( IncrCompSession :: NotInitialized ) ) ,
1496
+ incr_comp_session : RwLock :: new ( IncrCompSession :: NotInitialized ) ,
1498
1497
prof,
1499
1498
code_stats : Default :: default ( ) ,
1500
1499
optimization_fuel,
0 commit comments