@@ -7,9 +7,7 @@ use rustc_codegen_ssa::CodegenResults;
77use rustc_codegen_ssa:: traits:: CodegenBackend ;
88use rustc_data_structures:: steal:: Steal ;
99use rustc_data_structures:: svh:: Svh ;
10- use rustc_data_structures:: sync:: { OnceLock , WorkerLocal } ;
1110use rustc_hir:: def_id:: LOCAL_CRATE ;
12- use rustc_middle:: arena:: Arena ;
1311use rustc_middle:: dep_graph:: DepGraph ;
1412use rustc_middle:: ty:: { GlobalCtxt , TyCtxt } ;
1513use rustc_session:: Session ;
@@ -65,51 +63,18 @@ impl<'a, 'tcx> QueryResult<'a, &'tcx GlobalCtxt<'tcx>> {
6563
6664pub struct Queries < ' tcx > {
6765 compiler : & ' tcx Compiler ,
68- gcx_cell : OnceLock < GlobalCtxt < ' tcx > > ,
69-
70- arena : WorkerLocal < Arena < ' tcx > > ,
71- hir_arena : WorkerLocal < rustc_hir:: Arena < ' tcx > > ,
7266
7367 parse : Query < ast:: Crate > ,
74- // This just points to what's in `gcx_cell`.
75- gcx : Query < & ' tcx GlobalCtxt < ' tcx > > ,
7668}
7769
7870impl < ' tcx > Queries < ' tcx > {
7971 pub fn new ( compiler : & ' tcx Compiler ) -> Queries < ' tcx > {
80- Queries {
81- compiler,
82- gcx_cell : OnceLock :: new ( ) ,
83- arena : WorkerLocal :: new ( |_| Arena :: default ( ) ) ,
84- hir_arena : WorkerLocal :: new ( |_| rustc_hir:: Arena :: default ( ) ) ,
85- parse : Query { result : RefCell :: new ( None ) } ,
86- gcx : Query { result : RefCell :: new ( None ) } ,
87- }
88- }
89-
90- pub fn finish ( & ' tcx self ) {
91- if let Some ( gcx) = self . gcx_cell . get ( ) {
92- gcx. finish ( ) ;
93- }
72+ Queries { compiler, parse : Query { result : RefCell :: new ( None ) } }
9473 }
9574
9675 pub fn parse ( & self ) -> QueryResult < ' _ , ast:: Crate > {
9776 self . parse . compute ( || passes:: parse ( & self . compiler . sess ) )
9877 }
99-
100- pub fn global_ctxt ( & ' tcx self ) -> QueryResult < ' tcx , & ' tcx GlobalCtxt < ' tcx > > {
101- self . gcx . compute ( || {
102- let krate = self . parse ( ) . steal ( ) ;
103-
104- passes:: create_global_ctxt (
105- self . compiler ,
106- krate,
107- & self . gcx_cell ,
108- & self . arena ,
109- & self . hir_arena ,
110- )
111- } )
112- }
11378}
11479
11580pub struct Linker {
@@ -192,16 +157,7 @@ impl Compiler {
192157 where
193158 F : for < ' tcx > FnOnce ( & ' tcx Queries < ' tcx > ) -> T ,
194159 {
195- // Must declare `_timer` first so that it is dropped after `queries`.
196- let _timer;
197160 let queries = Queries :: new ( self ) ;
198- let ret = f ( & queries) ;
199-
200- // The timer's lifetime spans the dropping of `queries`, which contains
201- // the global context.
202- _timer = self . sess . timer ( "free_global_ctxt" ) ;
203- queries. finish ( ) ;
204-
205- ret
161+ f ( & queries)
206162 }
207163}
0 commit comments