@@ -220,11 +220,13 @@ enum WillExecute {
220
220
Disabled ,
221
221
}
222
222
223
- /// Should `--emit metadata` be used ?
223
+ /// What value should be passed to `--emit` ?
224
224
#[ derive( Copy , Clone ) ]
225
- enum EmitMetadata {
226
- Yes ,
227
- No ,
225
+ enum Emit {
226
+ None ,
227
+ Metadata ,
228
+ LlvmIr ,
229
+ Asm ,
228
230
}
229
231
230
232
impl < ' test > TestCx < ' test > {
@@ -424,7 +426,7 @@ impl<'test> TestCx<'test> {
424
426
}
425
427
426
428
let should_run = self . run_if_enabled ( ) ;
427
- let mut proc_res = self . compile_test ( should_run, EmitMetadata :: No ) ;
429
+ let mut proc_res = self . compile_test ( should_run, Emit :: None ) ;
428
430
429
431
if !proc_res. status . success ( ) {
430
432
self . fatal_proc_rec ( "compilation failed!" , & proc_res) ;
@@ -676,7 +678,7 @@ impl<'test> TestCx<'test> {
676
678
677
679
// compile test file (it should have 'compile-flags:-g' in the header)
678
680
let should_run = self . run_if_enabled ( ) ;
679
- let compile_result = self . compile_test ( should_run, EmitMetadata :: No ) ;
681
+ let compile_result = self . compile_test ( should_run, Emit :: None ) ;
680
682
if !compile_result. status . success ( ) {
681
683
self . fatal_proc_rec ( "compilation failed!" , & compile_result) ;
682
684
}
@@ -796,7 +798,7 @@ impl<'test> TestCx<'test> {
796
798
797
799
// compile test file (it should have 'compile-flags:-g' in the header)
798
800
let should_run = self . run_if_enabled ( ) ;
799
- let compiler_run_result = self . compile_test ( should_run, EmitMetadata :: No ) ;
801
+ let compiler_run_result = self . compile_test ( should_run, Emit :: None ) ;
800
802
if !compiler_run_result. status . success ( ) {
801
803
self . fatal_proc_rec ( "compilation failed!" , & compiler_run_result) ;
802
804
}
@@ -1028,7 +1030,7 @@ impl<'test> TestCx<'test> {
1028
1030
fn run_debuginfo_lldb_test_no_opt ( & self ) {
1029
1031
// compile test file (it should have 'compile-flags:-g' in the header)
1030
1032
let should_run = self . run_if_enabled ( ) ;
1031
- let compile_result = self . compile_test ( should_run, EmitMetadata :: No ) ;
1033
+ let compile_result = self . compile_test ( should_run, Emit :: None ) ;
1032
1034
if !compile_result. status . success ( ) {
1033
1035
self . fatal_proc_rec ( "compilation failed!" , & compile_result) ;
1034
1036
}
@@ -1453,21 +1455,21 @@ impl<'test> TestCx<'test> {
1453
1455
}
1454
1456
}
1455
1457
1456
- fn should_emit_metadata ( & self , pm : Option < PassMode > ) -> EmitMetadata {
1458
+ fn should_emit_metadata ( & self , pm : Option < PassMode > ) -> Emit {
1457
1459
match ( pm, self . props . fail_mode , self . config . mode ) {
1458
- ( Some ( PassMode :: Check ) , ..) | ( _, Some ( FailMode :: Check ) , Ui ) => EmitMetadata :: Yes ,
1459
- _ => EmitMetadata :: No ,
1460
+ ( Some ( PassMode :: Check ) , ..) | ( _, Some ( FailMode :: Check ) , Ui ) => Emit :: Metadata ,
1461
+ _ => Emit :: None ,
1460
1462
}
1461
1463
}
1462
1464
1463
- fn compile_test ( & self , will_execute : WillExecute , emit_metadata : EmitMetadata ) -> ProcRes {
1464
- self . compile_test_general ( will_execute, emit_metadata , self . props . local_pass_mode ( ) )
1465
+ fn compile_test ( & self , will_execute : WillExecute , emit : Emit ) -> ProcRes {
1466
+ self . compile_test_general ( will_execute, emit , self . props . local_pass_mode ( ) )
1465
1467
}
1466
1468
1467
1469
fn compile_test_general (
1468
1470
& self ,
1469
1471
will_execute : WillExecute ,
1470
- emit_metadata : EmitMetadata ,
1472
+ emit : Emit ,
1471
1473
local_pm : Option < PassMode > ,
1472
1474
) -> ProcRes {
1473
1475
// Only use `make_exe_name` when the test ends up being executed.
@@ -1502,7 +1504,7 @@ impl<'test> TestCx<'test> {
1502
1504
let rustc = self . make_compile_args (
1503
1505
& self . testpaths . file ,
1504
1506
output_file,
1505
- emit_metadata ,
1507
+ emit ,
1506
1508
allow_unused,
1507
1509
LinkToAux :: Yes ,
1508
1510
) ;
@@ -1735,7 +1737,7 @@ impl<'test> TestCx<'test> {
1735
1737
let mut aux_rustc = aux_cx. make_compile_args (
1736
1738
input_file,
1737
1739
aux_output,
1738
- EmitMetadata :: No ,
1740
+ Emit :: None ,
1739
1741
AllowUnused :: No ,
1740
1742
LinkToAux :: No ,
1741
1743
) ;
@@ -1875,7 +1877,7 @@ impl<'test> TestCx<'test> {
1875
1877
& self ,
1876
1878
input_file : & Path ,
1877
1879
output_file : TargetLocation ,
1878
- emit_metadata : EmitMetadata ,
1880
+ emit : Emit ,
1879
1881
allow_unused : AllowUnused ,
1880
1882
link_to_aux : LinkToAux ,
1881
1883
) -> Command {
@@ -1992,8 +1994,18 @@ impl<'test> TestCx<'test> {
1992
1994
}
1993
1995
}
1994
1996
1995
- if let ( false , EmitMetadata :: Yes ) = ( is_rustdoc, emit_metadata) {
1996
- rustc. args ( & [ "--emit" , "metadata" ] ) ;
1997
+ match emit {
1998
+ Emit :: None => { }
1999
+ Emit :: Metadata if is_rustdoc => { }
2000
+ Emit :: Metadata => {
2001
+ rustc. args ( & [ "--emit" , "metadata" ] ) ;
2002
+ }
2003
+ Emit :: LlvmIr => {
2004
+ rustc. args ( & [ "--emit" , "llvm-ir" ] ) ;
2005
+ }
2006
+ Emit :: Asm => {
2007
+ rustc. args ( & [ "--emit" , "asm" ] ) ;
2008
+ }
1997
2009
}
1998
2010
1999
2011
if !is_rustdoc {
@@ -2262,14 +2274,13 @@ impl<'test> TestCx<'test> {
2262
2274
fn compile_test_and_save_ir ( & self ) -> ProcRes {
2263
2275
let output_file = TargetLocation :: ThisDirectory ( self . output_base_dir ( ) ) ;
2264
2276
let input_file = & self . testpaths . file ;
2265
- let mut rustc = self . make_compile_args (
2277
+ let rustc = self . make_compile_args (
2266
2278
input_file,
2267
2279
output_file,
2268
- EmitMetadata :: No ,
2280
+ Emit :: LlvmIr ,
2269
2281
AllowUnused :: No ,
2270
2282
LinkToAux :: Yes ,
2271
2283
) ;
2272
- rustc. arg ( "--emit=llvm-ir" ) ;
2273
2284
2274
2285
self . compose_and_run_compiler ( rustc, None )
2275
2286
}
@@ -2281,17 +2292,11 @@ impl<'test> TestCx<'test> {
2281
2292
2282
2293
let output_file = TargetLocation :: ThisFile ( output_path. clone ( ) ) ;
2283
2294
let input_file = & self . testpaths . file ;
2284
- let mut rustc = self . make_compile_args (
2285
- input_file,
2286
- output_file,
2287
- EmitMetadata :: No ,
2288
- AllowUnused :: No ,
2289
- LinkToAux :: Yes ,
2290
- ) ;
2291
2295
2296
+ let mut emit = Emit :: None ;
2292
2297
match self . props . assembly_output . as_ref ( ) . map ( AsRef :: as_ref) {
2293
2298
Some ( "emit-asm" ) => {
2294
- rustc . arg ( "-- emit=asm" ) ;
2299
+ emit = Emit :: Asm ;
2295
2300
}
2296
2301
2297
2302
Some ( "ptx-linker" ) => {
@@ -2302,6 +2307,9 @@ impl<'test> TestCx<'test> {
2302
2307
None => self . fatal ( "missing 'assembly-output' header" ) ,
2303
2308
}
2304
2309
2310
+ let rustc =
2311
+ self . make_compile_args ( input_file, output_file, emit, AllowUnused :: No , LinkToAux :: Yes ) ;
2312
+
2305
2313
( self . compose_and_run_compiler ( rustc, None ) , output_path)
2306
2314
}
2307
2315
@@ -2426,7 +2434,7 @@ impl<'test> TestCx<'test> {
2426
2434
let mut rustc = new_rustdoc. make_compile_args (
2427
2435
& new_rustdoc. testpaths . file ,
2428
2436
output_file,
2429
- EmitMetadata :: No ,
2437
+ Emit :: None ,
2430
2438
AllowUnused :: Yes ,
2431
2439
LinkToAux :: Yes ,
2432
2440
) ;
@@ -2702,7 +2710,7 @@ impl<'test> TestCx<'test> {
2702
2710
fn run_codegen_units_test ( & self ) {
2703
2711
assert ! ( self . revision. is_none( ) , "revisions not relevant here" ) ;
2704
2712
2705
- let proc_res = self . compile_test ( WillExecute :: No , EmitMetadata :: No ) ;
2713
+ let proc_res = self . compile_test ( WillExecute :: No , Emit :: None ) ;
2706
2714
2707
2715
if !proc_res. status . success ( ) {
2708
2716
self . fatal_proc_rec ( "compilation failed!" , & proc_res) ;
@@ -3215,7 +3223,7 @@ impl<'test> TestCx<'test> {
3215
3223
if let Some ( FailMode :: Build ) = self . props . fail_mode {
3216
3224
// Make sure a build-fail test cannot fail due to failing analysis (e.g. typeck).
3217
3225
let pm = Some ( PassMode :: Check ) ;
3218
- let proc_res = self . compile_test_general ( WillExecute :: No , EmitMetadata :: Yes , pm) ;
3226
+ let proc_res = self . compile_test_general ( WillExecute :: No , Emit :: Metadata , pm) ;
3219
3227
self . check_if_test_should_compile ( & proc_res, pm) ;
3220
3228
}
3221
3229
0 commit comments