@@ -77,9 +77,9 @@ pub struct Queries<'tcx> {
77
77
Steal < ( ast:: Crate , Lrc < LintStore > ) > ,
78
78
Steal < Future < ' static , Option < DepGraphFuture > > > ,
79
79
) > ,
80
- expansion : Query < ( ast:: Crate , Steal < Rc < RefCell < BoxedResolver > > > , Lrc < LintStore > ) > ,
80
+ expansion : Query < ( Lrc < ast:: Crate > , Steal < Rc < RefCell < BoxedResolver > > > , Lrc < LintStore > ) > ,
81
81
dep_graph : Query < DepGraph > ,
82
- lower_to_hir : Query < ( & ' tcx map:: Forest < ' tcx > , Steal < ResolverOutputs > ) > ,
82
+ lower_to_hir : Query < ( & ' tcx map:: Forest < ' tcx > , Future < ' static , ( ) > , Steal < ResolverOutputs > ) > ,
83
83
prepare_outputs : Query < OutputFilenames > ,
84
84
global_ctxt : Query < QueryContext < ' tcx > > ,
85
85
ongoing_codegen : Query < Box < dyn Any > > ,
@@ -163,7 +163,7 @@ impl<'tcx> Queries<'tcx> {
163
163
164
164
pub fn expansion (
165
165
& self ,
166
- ) -> Result < & Query < ( ast:: Crate , Steal < Rc < RefCell < BoxedResolver > > > , Lrc < LintStore > ) > > {
166
+ ) -> Result < & Query < ( Lrc < ast:: Crate > , Steal < Rc < RefCell < BoxedResolver > > > , Lrc < LintStore > ) > > {
167
167
self . expansion . compute ( || {
168
168
let crate_name = self . crate_name ( ) ?. peek ( ) . clone ( ) ;
169
169
let ( krate, lint_store) = self . register_plugins ( ) ?. peek ( ) . 0 . steal ( ) ;
@@ -176,7 +176,7 @@ impl<'tcx> Queries<'tcx> {
176
176
& crate_name,
177
177
)
178
178
. map ( |( krate, resolver) | {
179
- ( krate, Steal :: new ( Rc :: new ( RefCell :: new ( resolver) ) ) , lint_store)
179
+ ( Lrc :: new ( krate) , Steal :: new ( Rc :: new ( RefCell :: new ( resolver) ) ) , lint_store)
180
180
} )
181
181
} )
182
182
}
@@ -204,25 +204,26 @@ impl<'tcx> Queries<'tcx> {
204
204
205
205
pub fn lower_to_hir (
206
206
& ' tcx self ,
207
- ) -> Result < & Query < ( & ' tcx map:: Forest < ' tcx > , Steal < ResolverOutputs > ) > > {
207
+ ) -> Result < & Query < ( & ' tcx map:: Forest < ' tcx > , Future < ' static , ( ) > , Steal < ResolverOutputs > ) > >
208
+ {
208
209
self . lower_to_hir . compute ( || {
209
210
let expansion_result = self . expansion ( ) ?;
210
211
let peeked = expansion_result. peek ( ) ;
211
- let krate = & peeked. 0 ;
212
+ let krate = peeked. 0 . clone ( ) ;
212
213
let resolver = peeked. 1 . steal ( ) ;
213
- let lint_store = & peeked. 2 ;
214
- let hir = resolver. borrow_mut ( ) . access ( |resolver| {
214
+ let lint_store = peeked. 2 . clone ( ) ;
215
+ let ( hir, lints ) = resolver. borrow_mut ( ) . access ( |resolver| {
215
216
passes:: lower_to_hir (
216
- self . session ( ) ,
217
+ self . session ( ) . clone ( ) ,
217
218
lint_store,
218
219
resolver,
219
220
& * self . dep_graph ( ) ?. peek ( ) ,
220
- & krate,
221
+ krate,
221
222
& self . arena ,
222
223
)
223
224
} ) ?;
224
225
let hir = self . arena . alloc ( hir) ;
225
- Ok ( ( hir, Steal :: new ( BoxedResolver :: to_resolver_outputs ( resolver) ) ) )
226
+ Ok ( ( hir, lints , Steal :: new ( BoxedResolver :: to_resolver_outputs ( resolver) ) ) )
226
227
} )
227
228
}
228
229
@@ -248,7 +249,7 @@ impl<'tcx> Queries<'tcx> {
248
249
let outputs = self . prepare_outputs ( ) ?. peek ( ) . clone ( ) ;
249
250
let lint_store = self . expansion ( ) ?. peek ( ) . 2 . clone ( ) ;
250
251
let hir = self . lower_to_hir ( ) ?. peek ( ) ;
251
- let ( ref hir_forest, ref resolver_outputs) = & * hir;
252
+ let ( ref hir_forest, _ , ref resolver_outputs) = & * hir;
252
253
let _timer = self . session ( ) . timer ( "create_global_ctxt" ) ;
253
254
Ok ( passes:: create_global_ctxt (
254
255
self . compiler ,
@@ -338,6 +339,12 @@ impl Compiler {
338
339
} ) ;
339
340
} ) ;
340
341
342
+ // Join the early lint check future if has started, but haven't been stolen yet.
343
+ let _join_lint_future = OnDrop ( || {
344
+ let result = queries. lower_to_hir . result . borrow_mut ( ) . take ( ) ;
345
+ result. map ( |result| result. map ( |result| result. 1 . join ( ) ) ) ;
346
+ } ) ;
347
+
341
348
let ret = f ( & queries) ;
342
349
343
350
if self . session ( ) . opts . debugging_opts . query_stats {
@@ -369,6 +376,7 @@ impl Compiler {
369
376
queries. global_ctxt ( ) ?;
370
377
371
378
// Drop AST after creating GlobalCtxt to free memory.
379
+ queries. lower_to_hir ( ) ?. take ( ) . 1 . join ( ) ;
372
380
mem:: drop ( queries. expansion ( ) ?. take ( ) ) ;
373
381
374
382
queries. ongoing_codegen ( ) ?;
0 commit comments