@@ -837,10 +837,9 @@ impl<'cfg> DrainState<'cfg> {
837
837
let mut sender = FinishOnDrop {
838
838
messages : & messages,
839
839
id,
840
- ok : false ,
840
+ result : None ,
841
841
} ;
842
- let result = job. run ( & state) ;
843
- sender. ok = true ;
842
+ sender. result = Some ( job. run ( & state) ) ;
844
843
845
844
// If the `rmeta_required` wasn't consumed but it was set
846
845
// previously, then we either have:
@@ -854,25 +853,26 @@ impl<'cfg> DrainState<'cfg> {
854
853
// we'll just naturally abort the compilation operation but for 1
855
854
// we need to make sure that the metadata is flagged as produced so
856
855
// 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 ( ) {
858
857
messages. push ( Message :: Finish ( id, Artifact :: Metadata , Ok ( ( ) ) ) ) ;
859
858
}
860
859
861
- messages. push ( Message :: Finish ( id, Artifact :: All , result) ) ;
862
-
863
860
// Use a helper struct with a `Drop` implementation to guarantee
864
861
// that a `Finish` message is sent even if our job panics. We
865
862
// shouldn't panic unless there's a bug in Cargo, so we just need
866
863
// to make sure nothing hangs by accident.
867
864
struct FinishOnDrop < ' a > {
868
865
messages : & ' a Queue < Message > ,
869
866
id : JobId ,
870
- ok : bool ,
867
+ result : Option < CargoResult < ( ) > > ,
871
868
}
872
869
873
870
impl Drop for FinishOnDrop < ' _ > {
874
871
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 {
876
876
self . messages . push ( Message :: Finish (
877
877
self . id ,
878
878
Artifact :: All ,
0 commit comments