diff --git a/compiler/rustc_codegen_ssa/src/back/write.rs b/compiler/rustc_codegen_ssa/src/back/write.rs index 9f22859ba81ca..8586615f7c764 100644 --- a/compiler/rustc_codegen_ssa/src/back/write.rs +++ b/compiler/rustc_codegen_ssa/src/back/write.rs @@ -1957,10 +1957,13 @@ impl Drop for Coordinator { pub struct OngoingCodegen { pub backend: B, pub crate_info: CrateInfo, - pub codegen_worker_receive: Receiver, - pub shared_emitter_main: SharedEmitterMain, pub output_filenames: Arc, + // Field order below is intended to terminate the coordinator thread before two fields below + // drop and prematurely close channels used by coordinator thread. See `Coordinator`'s + // `Drop` implementation for more info. pub coordinator: Coordinator, + pub codegen_worker_receive: Receiver, + pub shared_emitter_main: SharedEmitterMain, } impl OngoingCodegen {