@@ -58,7 +58,7 @@ use rustc_data_structures::stable_hasher::{HashStable, hash_stable_hashmap,
58
58
StableVec } ;
59
59
use arena:: { TypedArena , SyncDroplessArena } ;
60
60
use rustc_data_structures:: indexed_vec:: IndexVec ;
61
- use rustc_data_structures:: sync:: { Lrc , Lock } ;
61
+ use rustc_data_structures:: sync:: { self , Lrc , Lock , WorkerLocal } ;
62
62
use std:: any:: Any ;
63
63
use std:: borrow:: Borrow ;
64
64
use std:: cmp:: Ordering ;
@@ -80,14 +80,14 @@ use syntax_pos::Span;
80
80
use hir;
81
81
82
82
pub struct AllArenas < ' tcx > {
83
- pub global : GlobalArenas < ' tcx > ,
83
+ pub global : WorkerLocal < GlobalArenas < ' tcx > > ,
84
84
pub interner : SyncDroplessArena ,
85
85
}
86
86
87
87
impl < ' tcx > AllArenas < ' tcx > {
88
88
pub fn new ( ) -> Self {
89
89
AllArenas {
90
- global : GlobalArenas :: new ( ) ,
90
+ global : WorkerLocal :: new ( |_| GlobalArenas :: new ( ) ) ,
91
91
interner : SyncDroplessArena :: new ( ) ,
92
92
}
93
93
}
@@ -854,7 +854,7 @@ impl<'a, 'gcx, 'tcx> Deref for TyCtxt<'a, 'gcx, 'tcx> {
854
854
}
855
855
856
856
pub struct GlobalCtxt < ' tcx > {
857
- global_arenas : & ' tcx GlobalArenas < ' tcx > ,
857
+ global_arenas : & ' tcx WorkerLocal < GlobalArenas < ' tcx > > ,
858
858
global_interners : CtxtInterners < ' tcx > ,
859
859
860
860
cstore : & ' tcx CrateStoreDyn ,
@@ -1179,6 +1179,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
1179
1179
output_filenames : Arc :: new ( output_filenames. clone ( ) ) ,
1180
1180
} ;
1181
1181
1182
+ sync:: assert_send_val ( & gcx) ;
1183
+
1182
1184
tls:: enter_global ( gcx, f)
1183
1185
}
1184
1186
@@ -1704,7 +1706,7 @@ pub mod tls {
1704
1706
use ty:: maps;
1705
1707
use errors:: { Diagnostic , TRACK_DIAGNOSTICS } ;
1706
1708
use rustc_data_structures:: OnDrop ;
1707
- use rustc_data_structures:: sync:: Lrc ;
1709
+ use rustc_data_structures:: sync:: { self , Lrc } ;
1708
1710
use dep_graph:: OpenTask ;
1709
1711
1710
1712
/// This is the implicit state of rustc. It contains the current
@@ -1832,6 +1834,10 @@ pub mod tls {
1832
1834
if context == 0 {
1833
1835
f ( None )
1834
1836
} else {
1837
+ // We could get a ImplicitCtxt pointer from another thread.
1838
+ // Ensure that ImplicitCtxt is Sync
1839
+ sync:: assert_sync :: < ImplicitCtxt > ( ) ;
1840
+
1835
1841
unsafe { f ( Some ( & * ( context as * const ImplicitCtxt ) ) ) }
1836
1842
}
1837
1843
}
0 commit comments