Skip to content

Commit 56ddcac

Browse files
committed
Finish dep graph encoding before calling save_dep_graph and fix free_global_ctxt timing
1 parent b919f15 commit 56ddcac

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

compiler/rustc_interface/src/queries.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,11 @@ impl Compiler {
347347
let queries = Queries::new(self);
348348
let ret = f(&queries);
349349

350+
// Finish the dep graph encoding before we call `save_dep_graph`.
351+
if let Err((path, error)) = queries.finish() {
352+
self.sess.dcx().emit_fatal(errors::FailedWritingFile { path: &path, error });
353+
}
354+
350355
// NOTE: intentionally does not compute the global context if it hasn't been built yet,
351356
// since that likely means there was a parse error.
352357
if let Some(Ok(gcx)) = &mut *queries.gcx.result.borrow_mut() {
@@ -360,16 +365,13 @@ impl Compiler {
360365
}
361366

362367
self.sess.time("serialize_dep_graph", || gcx.enter(rustc_incremental::save_dep_graph));
363-
queries.dep_graph_serialized_tx.send(()).ok();
364368
}
365369

370+
queries.dep_graph_serialized_tx.send(()).ok();
371+
366372
// The timer's lifetime spans the dropping of `queries`, which contains
367373
// the global context.
368374
_timer = Some(self.sess.timer("free_global_ctxt"));
369-
if let Err((path, error)) = queries.finish() {
370-
self.sess.dcx().emit_fatal(errors::FailedWritingFile { path: &path, error });
371-
}
372-
373375
ret
374376
}
375377
}

0 commit comments

Comments
 (0)