@@ -77,9 +77,9 @@ pub struct Queries<'tcx> {
7777 Steal < ( ast:: Crate , Lrc < LintStore > ) > ,
7878 Steal < Future < ' static , Option < DepGraphFuture > > > ,
7979 ) > ,
80- expansion : Query < ( ast:: Crate , Steal < Rc < RefCell < BoxedResolver > > > , Lrc < LintStore > ) > ,
80+ expansion : Query < ( Lrc < ast:: Crate > , Steal < Rc < RefCell < BoxedResolver > > > , Lrc < LintStore > ) > ,
8181 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 > ) > ,
8383 prepare_outputs : Query < OutputFilenames > ,
8484 global_ctxt : Query < QueryContext < ' tcx > > ,
8585 ongoing_codegen : Query < Box < dyn Any > > ,
@@ -163,7 +163,7 @@ impl<'tcx> Queries<'tcx> {
163163
164164 pub fn expansion (
165165 & self ,
166- ) -> Result < & Query < ( ast:: Crate , Steal < Rc < RefCell < BoxedResolver > > > , Lrc < LintStore > ) > > {
166+ ) -> Result < & Query < ( Lrc < ast:: Crate > , Steal < Rc < RefCell < BoxedResolver > > > , Lrc < LintStore > ) > > {
167167 self . expansion . compute ( || {
168168 let crate_name = self . crate_name ( ) ?. peek ( ) . clone ( ) ;
169169 let ( krate, lint_store) = self . register_plugins ( ) ?. peek ( ) . 0 . steal ( ) ;
@@ -176,7 +176,7 @@ impl<'tcx> Queries<'tcx> {
176176 & crate_name,
177177 )
178178 . 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)
180180 } )
181181 } )
182182 }
@@ -204,25 +204,26 @@ impl<'tcx> Queries<'tcx> {
204204
205205 pub fn lower_to_hir (
206206 & ' tcx self ,
207- ) -> Result < & Query < ( & ' tcx map:: Forest < ' tcx > , Steal < ResolverOutputs > ) > > {
207+ ) -> Result < & Query < ( & ' tcx map:: Forest < ' tcx > , Future < ' static , ( ) > , Steal < ResolverOutputs > ) > >
208+ {
208209 self . lower_to_hir . compute ( || {
209210 let expansion_result = self . expansion ( ) ?;
210211 let peeked = expansion_result. peek ( ) ;
211- let krate = & peeked. 0 ;
212+ let krate = peeked. 0 . clone ( ) ;
212213 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| {
215216 passes:: lower_to_hir (
216- self . session ( ) ,
217+ self . session ( ) . clone ( ) ,
217218 lint_store,
218219 resolver,
219220 & * self . dep_graph ( ) ?. peek ( ) ,
220- & krate,
221+ krate,
221222 & self . arena ,
222223 )
223224 } ) ?;
224225 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) ) ) )
226227 } )
227228 }
228229
@@ -248,7 +249,7 @@ impl<'tcx> Queries<'tcx> {
248249 let outputs = self . prepare_outputs ( ) ?. peek ( ) . clone ( ) ;
249250 let lint_store = self . expansion ( ) ?. peek ( ) . 2 . clone ( ) ;
250251 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;
252253 let _timer = self . session ( ) . timer ( "create_global_ctxt" ) ;
253254 Ok ( passes:: create_global_ctxt (
254255 self . compiler ,
@@ -338,6 +339,12 @@ impl Compiler {
338339 } ) ;
339340 } ) ;
340341
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+
341348 let ret = f ( & queries) ;
342349
343350 if self . session ( ) . opts . debugging_opts . query_stats {
@@ -369,6 +376,7 @@ impl Compiler {
369376 queries. global_ctxt ( ) ?;
370377
371378 // Drop AST after creating GlobalCtxt to free memory.
379+ queries. lower_to_hir ( ) ?. take ( ) . 1 . join ( ) ;
372380 mem:: drop ( queries. expansion ( ) ?. take ( ) ) ;
373381
374382 queries. ongoing_codegen ( ) ?;
0 commit comments