@@ -7,9 +7,7 @@ use rustc_codegen_ssa::CodegenResults;
7
7
use rustc_codegen_ssa:: traits:: CodegenBackend ;
8
8
use rustc_data_structures:: steal:: Steal ;
9
9
use rustc_data_structures:: svh:: Svh ;
10
- use rustc_data_structures:: sync:: { OnceLock , WorkerLocal } ;
11
10
use rustc_hir:: def_id:: LOCAL_CRATE ;
12
- use rustc_middle:: arena:: Arena ;
13
11
use rustc_middle:: dep_graph:: DepGraph ;
14
12
use rustc_middle:: ty:: { GlobalCtxt , TyCtxt } ;
15
13
use rustc_session:: Session ;
@@ -65,51 +63,18 @@ impl<'a, 'tcx> QueryResult<'a, &'tcx GlobalCtxt<'tcx>> {
65
63
66
64
pub struct Queries < ' tcx > {
67
65
compiler : & ' tcx Compiler ,
68
- gcx_cell : OnceLock < GlobalCtxt < ' tcx > > ,
69
-
70
- arena : WorkerLocal < Arena < ' tcx > > ,
71
- hir_arena : WorkerLocal < rustc_hir:: Arena < ' tcx > > ,
72
66
73
67
parse : Query < ast:: Crate > ,
74
- // This just points to what's in `gcx_cell`.
75
- gcx : Query < & ' tcx GlobalCtxt < ' tcx > > ,
76
68
}
77
69
78
70
impl < ' tcx > Queries < ' tcx > {
79
71
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 ) } }
94
73
}
95
74
96
75
pub fn parse ( & self ) -> QueryResult < ' _ , ast:: Crate > {
97
76
self . parse . compute ( || passes:: parse ( & self . compiler . sess ) )
98
77
}
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
- }
113
78
}
114
79
115
80
pub struct Linker {
@@ -192,16 +157,7 @@ impl Compiler {
192
157
where
193
158
F : for < ' tcx > FnOnce ( & ' tcx Queries < ' tcx > ) -> T ,
194
159
{
195
- // Must declare `_timer` first so that it is dropped after `queries`.
196
- let _timer;
197
160
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)
206
162
}
207
163
}
0 commit comments