@@ -83,8 +83,7 @@ pub(crate) struct Queries {
83
83
codegen_channel : Query < ( Steal < mpsc:: Sender < Box < dyn Any + Send > > > ,
84
84
Steal < mpsc:: Receiver < Box < dyn Any + Send > > > ) > ,
85
85
global_ctxt : Query < BoxedGlobalCtxt > ,
86
- ongoing_codegen : Query < Box < dyn Any > > ,
87
- link : Query < ( ) > ,
86
+ codegen_and_link : Query < ( ) > ,
88
87
}
89
88
90
89
impl Compiler {
@@ -230,14 +229,14 @@ impl Compiler {
230
229
} )
231
230
}
232
231
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 ( || {
235
234
let rx = self . codegen_channel ( ) ?. peek ( ) . 1 . steal ( ) ;
236
235
let outputs = self . prepare_outputs ( ) ?;
237
- self . global_ctxt ( ) ?. peek_mut ( ) . enter ( |tcx| {
236
+ let ongoing_codegen = self . global_ctxt ( ) ?. peek_mut ( ) . enter ( |tcx| {
238
237
tcx. analysis ( LOCAL_CRATE ) . ok ( ) ;
239
238
240
- // Don't do code generation if there were any errors
239
+ // Don't do code generation if there were any errors.
241
240
self . session ( ) . compile_status ( ) ?;
242
241
243
242
Ok ( passes:: start_codegen (
@@ -246,21 +245,16 @@ impl Compiler {
246
245
rx,
247
246
& * outputs. peek ( )
248
247
) )
249
- } )
250
- } )
251
- }
252
-
253
- pub fn link ( & self ) -> Result < & Query < ( ) > > {
254
- self . queries . link . compute ( || {
255
- let sess = self . session ( ) ;
248
+ } ) ?;
256
249
257
- let ongoing_codegen = self . ongoing_codegen ( ) ?. take ( ) ;
250
+ // Drop GlobalCtxt after starting codegen to free memory.
251
+ mem:: drop ( self . global_ctxt ( ) ?. take ( ) ) ;
258
252
259
253
self . codegen_backend ( ) . join_codegen_and_link (
260
254
ongoing_codegen,
261
- sess ,
255
+ self . session ( ) ,
262
256
& * self . dep_graph ( ) ?. peek ( ) ,
263
- & * self . prepare_outputs ( ) ? . peek ( ) ,
257
+ & * outputs . peek ( ) ,
264
258
) . map_err ( |_| ErrorReported ) ?;
265
259
266
260
Ok ( ( ) )
@@ -281,11 +275,6 @@ impl Compiler {
281
275
// Drop AST after creating GlobalCtxt to free memory
282
276
mem:: drop ( self . expansion ( ) ?. take ( ) ) ;
283
277
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 ( |_| ( ) )
290
279
}
291
280
}
0 commit comments