@@ -83,8 +83,7 @@ pub(crate) struct Queries {
8383 codegen_channel : Query < ( Steal < mpsc:: Sender < Box < dyn Any + Send > > > ,
8484 Steal < mpsc:: Receiver < Box < dyn Any + Send > > > ) > ,
8585 global_ctxt : Query < BoxedGlobalCtxt > ,
86- ongoing_codegen : Query < Box < dyn Any > > ,
87- link : Query < ( ) > ,
86+ codegen_and_link : Query < ( ) > ,
8887}
8988
9089impl Compiler {
@@ -230,14 +229,14 @@ impl Compiler {
230229 } )
231230 }
232231
233- pub fn ongoing_codegen ( & self ) -> Result < & Query < Box < dyn Any > > > {
234- self . queries . ongoing_codegen . compute ( || {
232+ pub fn codegen_and_link ( & self ) -> Result < & Query < ( ) > > {
233+ self . queries . codegen_and_link . compute ( || {
235234 let rx = self . codegen_channel ( ) ?. peek ( ) . 1 . steal ( ) ;
236235 let outputs = self . prepare_outputs ( ) ?;
237- self . global_ctxt ( ) ?. peek_mut ( ) . enter ( |tcx| {
236+ let ongoing_codegen = self . global_ctxt ( ) ?. peek_mut ( ) . enter ( |tcx| {
238237 tcx. analysis ( LOCAL_CRATE ) . ok ( ) ;
239238
240- // Don't do code generation if there were any errors
239+ // Don't do code generation if there were any errors.
241240 self . session ( ) . compile_status ( ) ?;
242241
243242 Ok ( passes:: start_codegen (
@@ -246,21 +245,16 @@ impl Compiler {
246245 rx,
247246 & * outputs. peek ( )
248247 ) )
249- } )
250- } )
251- }
252-
253- pub fn link ( & self ) -> Result < & Query < ( ) > > {
254- self . queries . link . compute ( || {
255- let sess = self . session ( ) ;
248+ } ) ?;
256249
257- let ongoing_codegen = self . ongoing_codegen ( ) ?. take ( ) ;
250+ // Drop GlobalCtxt after starting codegen to free memory.
251+ mem:: drop ( self . global_ctxt ( ) ?. take ( ) ) ;
258252
259253 self . codegen_backend ( ) . join_codegen_and_link (
260254 ongoing_codegen,
261- sess ,
255+ self . session ( ) ,
262256 & * self . dep_graph ( ) ?. peek ( ) ,
263- & * self . prepare_outputs ( ) ? . peek ( ) ,
257+ & * outputs . peek ( ) ,
264258 ) . map_err ( |_| ErrorReported ) ?;
265259
266260 Ok ( ( ) )
@@ -281,11 +275,6 @@ impl Compiler {
281275 // Drop AST after creating GlobalCtxt to free memory
282276 mem:: drop ( self . expansion ( ) ?. take ( ) ) ;
283277
284- self . ongoing_codegen ( ) ?;
285-
286- // Drop GlobalCtxt after starting codegen to free memory
287- mem:: drop ( self . global_ctxt ( ) ?. take ( ) ) ;
288-
289- self . link ( ) . map ( |_| ( ) )
278+ self . codegen_and_link ( ) . map ( |_| ( ) )
290279 }
291280}
0 commit comments