Skip to content

Commit 5af00d0

Browse files
committed
Always send message through FinishOnDrop
1 parent 821d8ea commit 5af00d0

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/cargo/core/compiler/job_queue.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -837,10 +837,9 @@ impl<'cfg> DrainState<'cfg> {
837837
let mut sender = FinishOnDrop {
838838
messages: &messages,
839839
id,
840-
ok: false,
840+
result: None,
841841
};
842-
let result = job.run(&state);
843-
sender.ok = true;
842+
sender.result = Some(job.run(&state));
844843

845844
// If the `rmeta_required` wasn't consumed but it was set
846845
// previously, then we either have:
@@ -854,25 +853,26 @@ impl<'cfg> DrainState<'cfg> {
854853
// we'll just naturally abort the compilation operation but for 1
855854
// we need to make sure that the metadata is flagged as produced so
856855
// send a synthetic message here.
857-
if state.rmeta_required.get() && result.is_ok() {
856+
if state.rmeta_required.get() && sender.result.as_ref().unwrap().is_ok() {
858857
messages.push(Message::Finish(id, Artifact::Metadata, Ok(())));
859858
}
860859

861-
messages.push(Message::Finish(id, Artifact::All, result));
862-
863860
// Use a helper struct with a `Drop` implementation to guarantee
864861
// that a `Finish` message is sent even if our job panics. We
865862
// shouldn't panic unless there's a bug in Cargo, so we just need
866863
// to make sure nothing hangs by accident.
867864
struct FinishOnDrop<'a> {
868865
messages: &'a Queue<Message>,
869866
id: JobId,
870-
ok: bool,
867+
result: Option<CargoResult<()>>,
871868
}
872869

873870
impl Drop for FinishOnDrop<'_> {
874871
fn drop(&mut self) {
875-
if !self.ok {
872+
if let Some(result) = self.result.take() {
873+
self.messages
874+
.push(Message::Finish(self.id, Artifact::All, result));
875+
} else {
876876
self.messages.push(Message::Finish(
877877
self.id,
878878
Artifact::All,

0 commit comments

Comments
 (0)