@@ -17,7 +17,8 @@ use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
17
17
use rustc_data_structures:: jobserver:: { self , Client } ;
18
18
use rustc_data_structures:: profiling:: { duration_to_secs_str, SelfProfiler , SelfProfilerRef } ;
19
19
use 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 ,
21
22
} ;
22
23
use rustc_errors:: annotate_snippet_emitter_writer:: AnnotateSnippetEmitterWriter ;
23
24
use rustc_errors:: emitter:: { DynEmitter , EmitterWriter , HumanReadableErrorType } ;
@@ -39,7 +40,6 @@ use rustc_target::spec::{
39
40
DebuginfoKind , SanitizerSet , SplitDebuginfo , StackProtector , Target , TargetTriple , TlsModel ,
40
41
} ;
41
42
42
- use std:: cell:: { self , RefCell } ;
43
43
use std:: env;
44
44
use std:: fmt;
45
45
use std:: ops:: { Div , Mul } ;
@@ -152,7 +152,7 @@ pub struct Session {
152
152
/// Input, input file path and output file path to this compilation process.
153
153
pub io : CompilerIO ,
154
154
155
- incr_comp_session : OneThread < RefCell < IncrCompSession > > ,
155
+ incr_comp_session : RwLock < IncrCompSession > ,
156
156
/// Used for incremental compilation tests. Will only be populated if
157
157
/// `-Zquery-dep-graph` is specified.
158
158
pub cgu_reuse_tracker : CguReuseTracker ,
@@ -853,9 +853,9 @@ impl Session {
853
853
* incr_comp_session = IncrCompSession :: InvalidBecauseOfErrors { session_directory } ;
854
854
}
855
855
856
- pub fn incr_comp_session_dir ( & self ) -> cell :: Ref < ' _ , PathBuf > {
856
+ pub fn incr_comp_session_dir ( & self ) -> MappedReadGuard < ' _ , PathBuf > {
857
857
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 {
859
859
IncrCompSession :: NotInitialized => panic ! (
860
860
"trying to get session directory from `IncrCompSession`: {:?}" ,
861
861
* incr_comp_session,
@@ -868,7 +868,7 @@ impl Session {
868
868
} )
869
869
}
870
870
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 > > {
872
872
self . opts . incremental . as_ref ( ) . map ( |_| self . incr_comp_session_dir ( ) )
873
873
}
874
874
@@ -1460,7 +1460,7 @@ pub fn build_session(
1460
1460
parse_sess,
1461
1461
sysroot,
1462
1462
io,
1463
- incr_comp_session : OneThread :: new ( RefCell :: new ( IncrCompSession :: NotInitialized ) ) ,
1463
+ incr_comp_session : RwLock :: new ( IncrCompSession :: NotInitialized ) ,
1464
1464
cgu_reuse_tracker,
1465
1465
prof,
1466
1466
perf_stats : PerfStats {
0 commit comments