@@ -48,7 +48,6 @@ use crate::util::errors::{self, CargoResult, CargoResultExt, Internal, ProcessEr
48
48
use crate :: util:: machine_message:: Message ;
49
49
use crate :: util:: { self , machine_message, ProcessBuilder } ;
50
50
use crate :: util:: { internal, join_paths, paths, profile} ;
51
- use jobserver:: Client ;
52
51
53
52
/// A glorified callback for executing calls to rustc. Rather than calling rustc
54
53
/// directly, we'll use an `Executor`, giving clients an opportunity to intercept
@@ -172,7 +171,7 @@ fn rustc<'a, 'cfg>(
172
171
unit : & Unit < ' a > ,
173
172
exec : & Arc < dyn Executor > ,
174
173
) -> 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) ?;
176
175
let build_plan = cx. bcx . build_config . build_plan ;
177
176
178
177
let name = unit. pkg . name ( ) . to_string ( ) ;
@@ -287,16 +286,7 @@ fn rustc<'a, 'cfg>(
287
286
& target,
288
287
mode,
289
288
& 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) ,
300
290
)
301
291
. map_err ( internal_if_simple_exit_code)
302
292
. chain_err ( || format ! ( "could not compile `{}`." , name) ) ?;
@@ -544,22 +534,21 @@ fn prepare_rustc<'a, 'cfg>(
544
534
cx : & mut Context < ' a , ' cfg > ,
545
535
crate_types : & [ & str ] ,
546
536
unit : & Unit < ' a > ,
547
- ) -> CargoResult < ( Option < Client > , ProcessBuilder ) > {
537
+ ) -> CargoResult < ProcessBuilder > {
548
538
let is_primary = cx. is_primary_package ( unit) ;
549
539
550
540
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 {
552
542
let client = cx. new_jobserver ( ) ?;
553
543
base. inherit_jobserver ( & client) ;
554
544
base. arg ( "-Zjobserver-token-requests" ) ;
555
- Some ( client)
545
+ assert ! ( cx . rustc_clients . insert ( * unit , client) . is_none ( ) ) ;
556
546
} else {
557
547
base. inherit_jobserver ( & cx. jobserver ) ;
558
- None
559
- } ;
548
+ }
560
549
build_base_args ( cx, & mut base, unit, crate_types) ?;
561
550
build_deps_args ( & mut base, cx, unit) ?;
562
- Ok ( ( client , base) )
551
+ Ok ( base)
563
552
}
564
553
565
554
fn 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
618
607
rustdoc
619
608
. exec_with_streaming (
620
609
& 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) ,
624
611
false ,
625
612
)
626
613
. chain_err ( || format ! ( "Could not document `{}`." , name) ) ?;
@@ -1101,9 +1088,8 @@ fn on_stderr_line(
1101
1088
package_id : PackageId ,
1102
1089
target : & Target ,
1103
1090
options : & mut OutputOptions ,
1104
- rustc_client : & Option < Client > ,
1105
1091
) -> 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) ? {
1107
1093
// Check if caching is enabled.
1108
1094
if let Some ( ( path, cell) ) = & mut options. cache_cell {
1109
1095
// Cache the output, which will be replayed later when Fresh.
@@ -1123,7 +1109,6 @@ fn on_stderr_line_inner(
1123
1109
package_id : PackageId ,
1124
1110
target : & Target ,
1125
1111
options : & mut OutputOptions ,
1126
- rustc_client : & Option < Client > ,
1127
1112
) -> CargoResult < bool > {
1128
1113
// We primarily want to use this function to process JSON messages from
1129
1114
// rustc. The compiler should always print one JSON message per line, and
@@ -1250,14 +1235,9 @@ fn on_stderr_line_inner(
1250
1235
"found jobserver directive from rustc: `{:?}`" ,
1251
1236
jobserver_event
1252
1237
) ;
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 ( ) ,
1261
1241
}
1262
1242
return Ok ( false ) ;
1263
1243
}
@@ -1310,7 +1290,7 @@ fn replay_output_cache(
1310
1290
break ;
1311
1291
}
1312
1292
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) ?;
1314
1294
line. clear ( ) ;
1315
1295
}
1316
1296
Ok ( ( ) )
0 commit comments