@@ -1116,10 +1116,9 @@ actual:\n\
1116
1116
}
1117
1117
_ => { }
1118
1118
}
1119
- let ProcArgs { prog, args } = self . make_compile_args (
1119
+
1120
+ let rustc = self . make_compile_args (
1120
1121
extra_args, & self . testpaths . file , TargetLocation :: ThisFile ( self . make_exe_name ( ) ) ) ;
1121
- let mut rustc = Command :: new ( prog) ;
1122
- rustc. args ( args) ;
1123
1122
self . compose_and_run_compiler ( rustc, None )
1124
1123
}
1125
1124
@@ -1280,11 +1279,9 @@ actual:\n\
1280
1279
testpaths : & aux_testpaths,
1281
1280
revision : self . revision
1282
1281
} ;
1283
- let ProcArgs { prog , args } =
1282
+ let aux_rustc =
1284
1283
aux_cx. make_compile_args ( crate_type, & aux_testpaths. file , aux_output) ;
1285
- let mut rustc = Command :: new ( prog) ;
1286
- rustc. args ( & args) ;
1287
- let auxres = aux_cx. compose_and_run ( rustc,
1284
+ let auxres = aux_cx. compose_and_run ( aux_rustc,
1288
1285
aux_cx. config . compile_lib_path . to_str ( ) . unwrap ( ) ,
1289
1286
Some ( aux_dir. to_str ( ) . unwrap ( ) ) ,
1290
1287
None ) ;
@@ -1341,48 +1338,38 @@ actual:\n\
1341
1338
}
1342
1339
1343
1340
fn make_compile_args ( & self ,
1344
- extras : Vec < String > ,
1341
+ extra_args : Vec < String > ,
1345
1342
input_file : & Path ,
1346
1343
output_file : TargetLocation )
1347
- -> ProcArgs
1344
+ -> Command
1348
1345
{
1349
- let target = if self . props . force_host {
1350
- & * self . config . host
1351
- } else {
1352
- & * self . config . target
1353
- } ;
1354
-
1355
- // FIXME (#9639): This needs to handle non-utf8 paths
1356
- let mut args = vec ! [ input_file. to_str( ) . unwrap( ) . to_owned( ) ,
1357
- "-L" . to_owned( ) ,
1358
- self . config. build_base. to_str( ) . unwrap( ) . to_owned( ) ] ;
1346
+ let mut rustc = Command :: new ( & self . config . rustc_path ) ;
1347
+ rustc. arg ( input_file)
1348
+ . arg ( "-L" ) . arg ( & self . config . build_base ) ;
1359
1349
1360
1350
// Optionally prevent default --target if specified in test compile-flags.
1361
1351
let custom_target = self . props . compile_flags
1362
1352
. iter ( )
1363
1353
. fold ( false , |acc, x| acc || x. starts_with ( "--target" ) ) ;
1364
1354
1365
1355
if !custom_target {
1366
- args. extend ( vec ! [
1367
- format!( "--target={}" , target) ,
1368
- ] ) ;
1356
+ let target = if self . props . force_host {
1357
+ & * self . config . host
1358
+ } else {
1359
+ & * self . config . target
1360
+ } ;
1361
+
1362
+ rustc. arg ( & format ! ( "--target={}" , target) ) ;
1369
1363
}
1370
1364
1371
1365
if let Some ( revision) = self . revision {
1372
- args. extend ( vec ! [
1373
- "--cfg" . to_string( ) ,
1374
- revision. to_string( ) ,
1375
- ] ) ;
1366
+ rustc. args ( & [ "--cfg" , revision] ) ;
1376
1367
}
1377
1368
1378
1369
if let Some ( ref incremental_dir) = self . props . incremental_dir {
1379
- args. extend ( vec ! [
1380
- "-Z" . to_string( ) ,
1381
- format!( "incremental={}" , incremental_dir. display( ) ) ,
1382
- ] ) ;
1370
+ rustc. args ( & [ "-Z" , & format ! ( "incremental={}" , incremental_dir. display( ) ) ] ) ;
1383
1371
}
1384
1372
1385
-
1386
1373
match self . config . mode {
1387
1374
CompileFail |
1388
1375
ParseFail |
@@ -1391,27 +1378,22 @@ actual:\n\
1391
1378
// fashion, then you want JSON mode. Old-skool error
1392
1379
// patterns still match the raw compiler output.
1393
1380
if self . props . error_patterns . is_empty ( ) {
1394
- args. extend ( [ "--error-format" ,
1395
- "json" ]
1396
- . iter ( )
1397
- . map ( |s| s. to_string ( ) ) ) ;
1381
+ rustc. args ( & [ "--error-format" , "json" ] ) ;
1398
1382
}
1399
1383
}
1400
1384
MirOpt => {
1401
- args. extend ( [ "-Zdump-mir=all" ,
1402
- "-Zmir-opt-level=3" ,
1403
- "-Zdump-mir-exclude-pass-number" ]
1404
- . iter ( )
1405
- . map ( |s| s. to_string ( ) ) ) ;
1406
-
1385
+ rustc. args ( & [
1386
+ "-Zdump-mir=all" ,
1387
+ "-Zmir-opt-level=3" ,
1388
+ "-Zdump-mir-exclude-pass-number" ] ) ;
1407
1389
1408
1390
let mir_dump_dir = self . get_mir_dump_dir ( ) ;
1409
1391
create_dir_all ( mir_dump_dir. as_path ( ) ) . unwrap ( ) ;
1410
1392
let mut dir_opt = "-Zdump-mir-dir=" . to_string ( ) ;
1411
1393
dir_opt. push_str ( mir_dump_dir. to_str ( ) . unwrap ( ) ) ;
1412
1394
debug ! ( "dir_opt: {:?}" , dir_opt) ;
1413
1395
1414
- args . push ( dir_opt) ;
1396
+ rustc . arg ( dir_opt) ;
1415
1397
}
1416
1398
RunPass |
1417
1399
RunFail |
@@ -1428,32 +1410,30 @@ actual:\n\
1428
1410
}
1429
1411
}
1430
1412
1431
- args. extend_from_slice ( & extras) ;
1413
+ rustc. args ( & extra_args) ;
1414
+
1432
1415
if !self . props . no_prefer_dynamic {
1433
- args. push ( "-C" . to_owned ( ) ) ;
1434
- args. push ( "prefer-dynamic" . to_owned ( ) ) ;
1416
+ rustc. args ( & [ "-C" , "prefer-dynamic" ] ) ;
1435
1417
}
1436
- let path = match output_file {
1418
+
1419
+ match output_file {
1437
1420
TargetLocation :: ThisFile ( path) => {
1438
- args. push ( "-o" . to_owned ( ) ) ;
1439
- path
1421
+ rustc. arg ( "-o" ) . arg ( path) ;
1440
1422
}
1441
1423
TargetLocation :: ThisDirectory ( path) => {
1442
- args. push ( "--out-dir" . to_owned ( ) ) ;
1443
- path
1424
+ rustc. arg ( "--out-dir" ) . arg ( path) ;
1444
1425
}
1445
- } ;
1446
- args . push ( path . to_str ( ) . unwrap ( ) . to_owned ( ) ) ;
1426
+ }
1427
+
1447
1428
if self . props . force_host {
1448
- args . extend ( self . split_maybe_args ( & self . config . host_rustcflags ) ) ;
1429
+ rustc . args ( self . split_maybe_args ( & self . config . host_rustcflags ) ) ;
1449
1430
} else {
1450
- args. extend ( self . split_maybe_args ( & self . config . target_rustcflags ) ) ;
1451
- }
1452
- args. extend ( self . props . compile_flags . iter ( ) . cloned ( ) ) ;
1453
- ProcArgs {
1454
- prog : self . config . rustc_path . to_str ( ) . unwrap ( ) . to_owned ( ) ,
1455
- args,
1431
+ rustc. args ( self . split_maybe_args ( & self . config . target_rustcflags ) ) ;
1456
1432
}
1433
+
1434
+ rustc. args ( & self . props . compile_flags ) ;
1435
+
1436
+ rustc
1457
1437
}
1458
1438
1459
1439
fn make_lib_name ( & self , auxfile : & Path ) -> PathBuf {
@@ -1660,15 +1640,12 @@ actual:\n\
1660
1640
aux_dir. to_str( ) . unwrap( ) . to_owned( ) ] ;
1661
1641
let llvm_args = vec ! [ "--emit=llvm-ir" . to_owned( ) , ] ;
1662
1642
link_args. extend ( llvm_args) ;
1663
- let args = self . make_compile_args ( link_args,
1664
- & self . testpaths . file ,
1665
- TargetLocation :: ThisDirectory (
1666
- self . output_base_name ( ) . parent ( )
1667
- . unwrap ( )
1668
- . to_path_buf ( ) ) ) ;
1669
- let ProcArgs { prog, args } = args;
1670
- let mut rustc = Command :: new ( prog) ;
1671
- rustc. args ( args) ;
1643
+ let rustc = self . make_compile_args ( link_args,
1644
+ & self . testpaths . file ,
1645
+ TargetLocation :: ThisDirectory (
1646
+ self . output_base_name ( ) . parent ( )
1647
+ . unwrap ( )
1648
+ . to_path_buf ( ) ) ) ;
1672
1649
self . compose_and_run_compiler ( rustc, None )
1673
1650
}
1674
1651
0 commit comments