@@ -78,15 +78,13 @@ use crate::hir;
7878pub struct AllArenas < ' tcx > {
7979 pub global : WorkerLocal < GlobalArenas < ' tcx > > ,
8080 pub interner : SyncDroplessArena ,
81- global_ctxt : Option < GlobalCtxt < ' tcx > > ,
8281}
8382
8483impl < ' tcx > AllArenas < ' tcx > {
8584 pub fn new ( ) -> Self {
8685 AllArenas {
8786 global : WorkerLocal :: new ( |_| GlobalArenas :: default ( ) ) ,
8887 interner : SyncDroplessArena :: default ( ) ,
89- global_ctxt : None ,
9088 }
9189 }
9290}
@@ -1182,20 +1180,19 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
11821180 /// to the context. The closure enforces that the type context and any interned
11831181 /// value (types, substs, etc.) can only be used while `ty::tls` has a valid
11841182 /// reference to the context, to allow formatting values that need it.
1185- pub fn create_and_enter < F , R > ( s : & ' tcx Session ,
1186- cstore : & ' tcx CrateStoreDyn ,
1187- local_providers : ty:: query:: Providers < ' tcx > ,
1188- extern_providers : ty:: query:: Providers < ' tcx > ,
1189- arenas : & ' tcx mut AllArenas < ' tcx > ,
1190- resolutions : ty:: Resolutions ,
1191- hir : hir_map:: Map < ' tcx > ,
1192- on_disk_query_result_cache : query:: OnDiskCache < ' tcx > ,
1193- crate_name : & str ,
1194- tx : mpsc:: Sender < Box < dyn Any + Send > > ,
1195- output_filenames : & OutputFilenames ,
1196- f : F ) -> R
1197- where F : for < ' b > FnOnce ( TyCtxt < ' b , ' tcx , ' tcx > ) -> R
1198- {
1183+ pub fn create_global_ctxt (
1184+ s : & ' tcx Session ,
1185+ cstore : & ' tcx CrateStoreDyn ,
1186+ local_providers : ty:: query:: Providers < ' tcx > ,
1187+ extern_providers : ty:: query:: Providers < ' tcx > ,
1188+ arenas : & ' tcx AllArenas < ' tcx > ,
1189+ resolutions : ty:: Resolutions ,
1190+ hir : hir_map:: Map < ' tcx > ,
1191+ on_disk_query_result_cache : query:: OnDiskCache < ' tcx > ,
1192+ crate_name : & str ,
1193+ tx : mpsc:: Sender < Box < dyn Any + Send > > ,
1194+ output_filenames : & OutputFilenames ,
1195+ ) -> GlobalCtxt < ' tcx > {
11991196 let data_layout = TargetDataLayout :: parse ( & s. target . target ) . unwrap_or_else ( |err| {
12001197 s. fatal ( & err) ;
12011198 } ) ;
@@ -1247,7 +1244,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
12471244 Lrc :: new ( StableVec :: new ( v) ) ) ;
12481245 }
12491246
1250- arenas . global_ctxt = Some ( GlobalCtxt {
1247+ GlobalCtxt {
12511248 sess : s,
12521249 cstore,
12531250 global_arenas : & arenas. global ,
@@ -1293,15 +1290,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
12931290 alloc_map : Lock :: new ( interpret:: AllocMap :: new ( ) ) ,
12941291 tx_to_llvm_workers : Lock :: new ( tx) ,
12951292 output_filenames : Arc :: new ( output_filenames. clone ( ) ) ,
1296- } ) ;
1297-
1298- let gcx = arenas. global_ctxt . as_ref ( ) . unwrap ( ) ;
1299-
1300- let r = tls:: enter_global ( gcx, f) ;
1301-
1302- gcx. queries . record_computed_queries ( s) ;
1303-
1304- r
1293+ }
13051294 }
13061295
13071296 pub fn consider_optimizing < T : Fn ( ) -> String > ( & self , msg : T ) -> bool {
@@ -1985,31 +1974,29 @@ pub mod tls {
19851974 pub fn enter_global < ' gcx , F , R > ( gcx : & ' gcx GlobalCtxt < ' gcx > , f : F ) -> R
19861975 where F : FnOnce ( TyCtxt < ' gcx , ' gcx , ' gcx > ) -> R
19871976 {
1988- with_thread_locals ( || {
1989- // Update GCX_PTR to indicate there's a GlobalCtxt available
1990- GCX_PTR . with ( |lock| {
1991- * lock. lock ( ) = gcx as * const _ as usize ;
1992- } ) ;
1993- // Set GCX_PTR back to 0 when we exit
1994- let _on_drop = OnDrop ( move || {
1995- GCX_PTR . with ( |lock| * lock. lock ( ) = 0 ) ;
1996- } ) ;
1977+ // Update GCX_PTR to indicate there's a GlobalCtxt available
1978+ GCX_PTR . with ( |lock| {
1979+ * lock. lock ( ) = gcx as * const _ as usize ;
1980+ } ) ;
1981+ // Set GCX_PTR back to 0 when we exit
1982+ let _on_drop = OnDrop ( move || {
1983+ GCX_PTR . with ( |lock| * lock. lock ( ) = 0 ) ;
1984+ } ) ;
19971985
1998- let tcx = TyCtxt {
1999- gcx,
2000- interners : & gcx. global_interners ,
2001- dummy : PhantomData ,
2002- } ;
2003- let icx = ImplicitCtxt {
2004- tcx,
2005- query : None ,
2006- diagnostics : None ,
2007- layout_depth : 0 ,
2008- task_deps : None ,
2009- } ;
2010- enter_context ( & icx, |_| {
2011- f ( tcx)
2012- } )
1986+ let tcx = TyCtxt {
1987+ gcx,
1988+ interners : & gcx. global_interners ,
1989+ dummy : PhantomData ,
1990+ } ;
1991+ let icx = ImplicitCtxt {
1992+ tcx,
1993+ query : None ,
1994+ diagnostics : None ,
1995+ layout_depth : 0 ,
1996+ task_deps : None ,
1997+ } ;
1998+ enter_context ( & icx, |_| {
1999+ f ( tcx)
20132000 } )
20142001 }
20152002
0 commit comments