@@ -14,7 +14,9 @@ use rustc_data_structures::flock;
14
14
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
- 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
+ } ;
18
20
use rustc_errors:: annotate_snippet_emitter_writer:: AnnotateSnippetEmitter ;
19
21
use rustc_errors:: emitter:: { DynEmitter , HumanEmitter , HumanReadableErrorType } ;
20
22
use rustc_errors:: json:: JsonEmitter ;
@@ -35,7 +37,6 @@ use rustc_target::spec::{
35
37
} ;
36
38
37
39
use std:: any:: Any ;
38
- use std:: cell:: { self , RefCell } ;
39
40
use std:: env;
40
41
use std:: fmt;
41
42
use std:: ops:: { Div , Mul } ;
@@ -149,7 +150,7 @@ pub struct Session {
149
150
/// Input, input file path and output file path to this compilation process.
150
151
pub io : CompilerIO ,
151
152
152
- incr_comp_session : OneThread < RefCell < IncrCompSession > > ,
153
+ incr_comp_session : RwLock < IncrCompSession > ,
153
154
154
155
/// Used by `-Z self-profile`.
155
156
pub prof : SelfProfilerRef ,
@@ -533,9 +534,9 @@ impl Session {
533
534
* incr_comp_session = IncrCompSession :: InvalidBecauseOfErrors { session_directory } ;
534
535
}
535
536
536
- pub fn incr_comp_session_dir ( & self ) -> cell :: Ref < ' _ , PathBuf > {
537
+ pub fn incr_comp_session_dir ( & self ) -> MappedReadGuard < ' _ , PathBuf > {
537
538
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 {
539
540
IncrCompSession :: NotInitialized => panic ! (
540
541
"trying to get session directory from `IncrCompSession`: {:?}" ,
541
542
* incr_comp_session,
@@ -548,7 +549,7 @@ impl Session {
548
549
} )
549
550
}
550
551
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 > > {
552
553
self . opts . incremental . as_ref ( ) . map ( |_| self . incr_comp_session_dir ( ) )
553
554
}
554
555
@@ -1176,7 +1177,7 @@ pub fn build_session(
1176
1177
parse_sess,
1177
1178
sysroot,
1178
1179
io,
1179
- incr_comp_session : OneThread :: new ( RefCell :: new ( IncrCompSession :: NotInitialized ) ) ,
1180
+ incr_comp_session : RwLock :: new ( IncrCompSession :: NotInitialized ) ,
1180
1181
prof,
1181
1182
code_stats : Default :: default ( ) ,
1182
1183
optimization_fuel,
0 commit comments