@@ -457,10 +457,8 @@ impl<'cfg> JobQueue<'cfg> {
457
457
. map ( move |srv| srv. start ( move |msg| messages. push ( Message :: FixDiagnostic ( msg) ) ) ) ;
458
458
459
459
crossbeam_utils:: thread:: scope ( move |scope| {
460
- match state. drain_the_queue ( cx, plan, scope, & helper) {
461
- Some ( err) => Err ( err) ,
462
- None => Ok ( ( ) ) ,
463
- }
460
+ let ( result, ) = state. drain_the_queue ( cx, plan, scope, & helper) ;
461
+ result
464
462
} )
465
463
. expect ( "child threads shouldn't panic" )
466
464
}
@@ -691,15 +689,16 @@ impl<'cfg> DrainState<'cfg> {
691
689
/// This is the "main" loop, where Cargo does all work to run the
692
690
/// compiler.
693
691
///
694
- /// This returns an Option to prevent the use of `?` on `Result` types
695
- /// because it is important for the loop to carefully handle errors.
692
+ /// This returns a tuple of `Result` to prevent the use of `?` on
693
+ /// `Result` types because it is important for the loop to
694
+ /// carefully handle errors.
696
695
fn drain_the_queue (
697
696
mut self ,
698
697
cx : & mut Context < ' _ , ' _ > ,
699
698
plan : & mut BuildPlan ,
700
699
scope : & Scope < ' _ > ,
701
700
jobserver_helper : & HelperThread ,
702
- ) -> Option < anyhow:: Error > {
701
+ ) -> ( Result < ( ) , anyhow:: Error > , ) {
703
702
trace ! ( "queue: {:#?}" , self . queue) ;
704
703
705
704
// Iteratively execute the entire dependency graph. Each turn of the
@@ -769,7 +768,7 @@ impl<'cfg> DrainState<'cfg> {
769
768
if error. is_some ( ) {
770
769
crate :: display_error ( & e, & mut cx. bcx . config . shell ( ) ) ;
771
770
} else {
772
- return Some ( e ) ;
771
+ return ( Err ( e ) , ) ;
773
772
}
774
773
}
775
774
if cx. bcx . build_config . emit_json ( ) {
@@ -782,13 +781,13 @@ impl<'cfg> DrainState<'cfg> {
782
781
if error. is_some ( ) {
783
782
crate :: display_error ( & e. into ( ) , & mut shell) ;
784
783
} else {
785
- return Some ( e. into ( ) ) ;
784
+ return ( Err ( e. into ( ) ) , ) ;
786
785
}
787
786
}
788
787
}
789
788
790
789
if let Some ( e) = error {
791
- Some ( e )
790
+ ( Err ( e ) , )
792
791
} else if self . queue . is_empty ( ) && self . pending_queue . is_empty ( ) {
793
792
let message = format ! (
794
793
"{} [{}] target(s) in {}" ,
@@ -800,10 +799,10 @@ impl<'cfg> DrainState<'cfg> {
800
799
self . emit_future_incompat ( cx) ;
801
800
}
802
801
803
- None
802
+ ( Ok ( ( ) ) , )
804
803
} else {
805
804
debug ! ( "queue: {:#?}" , self . queue) ;
806
- Some ( internal ( "finished with jobs still left in the queue" ) )
805
+ ( Err ( internal ( "finished with jobs still left in the queue" ) ) , )
807
806
}
808
807
}
809
808
0 commit comments