@@ -48,7 +48,6 @@ use crate::util::errors::{self, CargoResult, CargoResultExt, Internal, ProcessEr
4848use crate :: util:: machine_message:: Message ;
4949use crate :: util:: { self , machine_message, ProcessBuilder } ;
5050use crate :: util:: { internal, join_paths, paths, profile} ;
51- use jobserver:: Client ;
5251
5352/// A glorified callback for executing calls to rustc. Rather than calling rustc
5453/// directly, we'll use an `Executor`, giving clients an opportunity to intercept
@@ -172,7 +171,7 @@ fn rustc<'a, 'cfg>(
172171 unit : & Unit < ' a > ,
173172 exec : & Arc < dyn Executor > ,
174173) -> CargoResult < Work > {
175- let ( rustc_client , mut rustc) = prepare_rustc ( cx, & unit. target . rustc_crate_types ( ) , unit) ?;
174+ let mut rustc = prepare_rustc ( cx, & unit. target . rustc_crate_types ( ) , unit) ?;
176175 let build_plan = cx. bcx . build_config . build_plan ;
177176
178177 let name = unit. pkg . name ( ) . to_string ( ) ;
@@ -287,16 +286,7 @@ fn rustc<'a, 'cfg>(
287286 & target,
288287 mode,
289288 & mut |line| on_stdout_line ( state, line, package_id, & target) ,
290- & mut |line| {
291- on_stderr_line (
292- state,
293- line,
294- package_id,
295- & target,
296- & mut output_options,
297- & rustc_client,
298- )
299- } ,
289+ & mut |line| on_stderr_line ( state, line, package_id, & target, & mut output_options) ,
300290 )
301291 . map_err ( internal_if_simple_exit_code)
302292 . chain_err ( || format ! ( "could not compile `{}`." , name) ) ?;
@@ -544,22 +534,21 @@ fn prepare_rustc<'a, 'cfg>(
544534 cx : & mut Context < ' a , ' cfg > ,
545535 crate_types : & [ & str ] ,
546536 unit : & Unit < ' a > ,
547- ) -> CargoResult < ( Option < Client > , ProcessBuilder ) > {
537+ ) -> CargoResult < ProcessBuilder > {
548538 let is_primary = cx. is_primary_package ( unit) ;
549539
550540 let mut base = cx. compilation . rustc_process ( unit. pkg , is_primary) ?;
551- let client = if cx. bcx . config . cli_unstable ( ) . jobserver_per_rustc {
541+ if cx. bcx . config . cli_unstable ( ) . jobserver_per_rustc {
552542 let client = cx. new_jobserver ( ) ?;
553543 base. inherit_jobserver ( & client) ;
554544 base. arg ( "-Zjobserver-token-requests" ) ;
555- Some ( client)
545+ assert ! ( cx . rustc_clients . insert ( * unit , client) . is_none ( ) ) ;
556546 } else {
557547 base. inherit_jobserver ( & cx. jobserver ) ;
558- None
559- } ;
548+ }
560549 build_base_args ( cx, & mut base, unit, crate_types) ?;
561550 build_deps_args ( & mut base, cx, unit) ?;
562- Ok ( ( client , base) )
551+ Ok ( base)
563552}
564553
565554fn rustdoc < ' a , ' cfg > ( cx : & mut Context < ' a , ' cfg > , unit : & Unit < ' a > ) -> CargoResult < Work > {
@@ -618,9 +607,7 @@ fn rustdoc<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> CargoResult
618607 rustdoc
619608 . exec_with_streaming (
620609 & mut |line| on_stdout_line ( state, line, package_id, & target) ,
621- & mut |line| {
622- on_stderr_line ( state, line, package_id, & target, & mut output_options, & None )
623- } ,
610+ & mut |line| on_stderr_line ( state, line, package_id, & target, & mut output_options) ,
624611 false ,
625612 )
626613 . chain_err ( || format ! ( "Could not document `{}`." , name) ) ?;
@@ -1101,9 +1088,8 @@ fn on_stderr_line(
11011088 package_id : PackageId ,
11021089 target : & Target ,
11031090 options : & mut OutputOptions ,
1104- rustc_client : & Option < Client > ,
11051091) -> CargoResult < ( ) > {
1106- if on_stderr_line_inner ( state, line, package_id, target, options, rustc_client ) ? {
1092+ if on_stderr_line_inner ( state, line, package_id, target, options) ? {
11071093 // Check if caching is enabled.
11081094 if let Some ( ( path, cell) ) = & mut options. cache_cell {
11091095 // Cache the output, which will be replayed later when Fresh.
@@ -1123,7 +1109,6 @@ fn on_stderr_line_inner(
11231109 package_id : PackageId ,
11241110 target : & Target ,
11251111 options : & mut OutputOptions ,
1126- rustc_client : & Option < Client > ,
11271112) -> CargoResult < bool > {
11281113 // We primarily want to use this function to process JSON messages from
11291114 // rustc. The compiler should always print one JSON message per line, and
@@ -1250,14 +1235,9 @@ fn on_stderr_line_inner(
12501235 "found jobserver directive from rustc: `{:?}`" ,
12511236 jobserver_event
12521237 ) ;
1253- match rustc_client {
1254- Some ( client) => match jobserver_event {
1255- Event :: WillAcquire => state. will_acquire ( client) ,
1256- Event :: Release => state. release_token ( ) ,
1257- } ,
1258- None => {
1259- panic ! ( "Received jobserver event without a client" ) ;
1260- }
1238+ match jobserver_event {
1239+ Event :: WillAcquire => state. will_acquire ( ) ,
1240+ Event :: Release => state. release_token ( ) ,
12611241 }
12621242 return Ok ( false ) ;
12631243 }
@@ -1310,7 +1290,7 @@ fn replay_output_cache(
13101290 break ;
13111291 }
13121292 let trimmed = line. trim_end_matches ( & [ '\n' , '\r' ] [ ..] ) ;
1313- on_stderr_line ( state, trimmed, package_id, & target, & mut options, & None ) ?;
1293+ on_stderr_line ( state, trimmed, package_id, & target, & mut options) ?;
13141294 line. clear ( ) ;
13151295 }
13161296 Ok ( ( ) )
0 commit comments