@@ -53,7 +53,6 @@ use std::cell::Cell;
53
53
use std:: collections:: { BTreeMap , HashMap , HashSet } ;
54
54
use std:: io;
55
55
use std:: marker;
56
- use std:: mem;
57
56
use std:: sync:: Arc ;
58
57
use std:: time:: Duration ;
59
58
@@ -838,9 +837,10 @@ impl<'cfg> DrainState<'cfg> {
838
837
let mut sender = FinishOnDrop {
839
838
messages : & messages,
840
839
id,
841
- result : Err ( format_err ! ( "worker panicked" ) ) ,
840
+ ok : false ,
842
841
} ;
843
- sender. result = job. run ( & state) ;
842
+ let result = job. run ( & state) ;
843
+ sender. ok = true ;
844
844
845
845
// If the `rmeta_required` wasn't consumed but it was set
846
846
// previously, then we either have:
@@ -854,25 +854,31 @@ impl<'cfg> DrainState<'cfg> {
854
854
// we'll just naturally abort the compilation operation but for 1
855
855
// we need to make sure that the metadata is flagged as produced so
856
856
// send a synthetic message here.
857
- if state. rmeta_required . get ( ) && sender . result . is_ok ( ) {
857
+ if state. rmeta_required . get ( ) && result. is_ok ( ) {
858
858
messages. push ( Message :: Finish ( id, Artifact :: Metadata , Ok ( ( ) ) ) ) ;
859
859
}
860
860
861
+ messages. push ( Message :: Finish ( id, Artifact :: All , result) ) ;
862
+
861
863
// Use a helper struct with a `Drop` implementation to guarantee
862
864
// that a `Finish` message is sent even if our job panics. We
863
865
// shouldn't panic unless there's a bug in Cargo, so we just need
864
866
// to make sure nothing hangs by accident.
865
867
struct FinishOnDrop < ' a > {
866
868
messages : & ' a Queue < Message > ,
867
869
id : JobId ,
868
- result : CargoResult < ( ) > ,
870
+ ok : bool ,
869
871
}
870
872
871
873
impl Drop for FinishOnDrop < ' _ > {
872
874
fn drop ( & mut self ) {
873
- let msg = mem:: replace ( & mut self . result , Ok ( ( ) ) ) ;
874
- self . messages
875
- . push ( Message :: Finish ( self . id , Artifact :: All , msg) ) ;
875
+ if !self . ok {
876
+ self . messages . push ( Message :: Finish (
877
+ self . id ,
878
+ Artifact :: All ,
879
+ Err ( format_err ! ( "worker panicked" ) ) ,
880
+ ) ) ;
881
+ }
876
882
}
877
883
}
878
884
} ;
0 commit comments