From 5af00d0e61bd5ca6fbdf378c6a11be0ac7dd38e6 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 9 Nov 2020 17:21:18 +0100 Subject: [PATCH] Always send message through FinishOnDrop --- src/cargo/core/compiler/job_queue.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/cargo/core/compiler/job_queue.rs b/src/cargo/core/compiler/job_queue.rs index 9ebcf96d124..791c8fd170c 100644 --- a/src/cargo/core/compiler/job_queue.rs +++ b/src/cargo/core/compiler/job_queue.rs @@ -837,10 +837,9 @@ impl<'cfg> DrainState<'cfg> { let mut sender = FinishOnDrop { messages: &messages, id, - ok: false, + result: None, }; - let result = job.run(&state); - sender.ok = true; + sender.result = Some(job.run(&state)); // If the `rmeta_required` wasn't consumed but it was set // previously, then we either have: @@ -854,12 +853,10 @@ impl<'cfg> DrainState<'cfg> { // we'll just naturally abort the compilation operation but for 1 // we need to make sure that the metadata is flagged as produced so // send a synthetic message here. - if state.rmeta_required.get() && result.is_ok() { + if state.rmeta_required.get() && sender.result.as_ref().unwrap().is_ok() { messages.push(Message::Finish(id, Artifact::Metadata, Ok(()))); } - messages.push(Message::Finish(id, Artifact::All, result)); - // Use a helper struct with a `Drop` implementation to guarantee // that a `Finish` message is sent even if our job panics. We // shouldn't panic unless there's a bug in Cargo, so we just need @@ -867,12 +864,15 @@ impl<'cfg> DrainState<'cfg> { struct FinishOnDrop<'a> { messages: &'a Queue, id: JobId, - ok: bool, + result: Option>, } impl Drop for FinishOnDrop<'_> { fn drop(&mut self) { - if !self.ok { + if let Some(result) = self.result.take() { + self.messages + .push(Message::Finish(self.id, Artifact::All, result)); + } else { self.messages.push(Message::Finish( self.id, Artifact::All,