@@ -220,11 +220,13 @@ enum WillExecute {
220220 Disabled ,
221221}
222222
223- /// Should `--emit metadata` be used ?
223+ /// What value should be passed to `--emit` ?
224224#[ derive( Copy , Clone ) ]
225- enum EmitMetadata {
226- Yes ,
227- No ,
225+ enum Emit {
226+ None ,
227+ Metadata ,
228+ LlvmIr ,
229+ Asm ,
228230}
229231
230232impl < ' test > TestCx < ' test > {
@@ -424,7 +426,7 @@ impl<'test> TestCx<'test> {
424426 }
425427
426428 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 ) ;
428430
429431 if !proc_res. status . success ( ) {
430432 self . fatal_proc_rec ( "compilation failed!" , & proc_res) ;
@@ -676,7 +678,7 @@ impl<'test> TestCx<'test> {
676678
677679 // compile test file (it should have 'compile-flags:-g' in the header)
678680 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 ) ;
680682 if !compile_result. status . success ( ) {
681683 self . fatal_proc_rec ( "compilation failed!" , & compile_result) ;
682684 }
@@ -796,7 +798,7 @@ impl<'test> TestCx<'test> {
796798
797799 // compile test file (it should have 'compile-flags:-g' in the header)
798800 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 ) ;
800802 if !compiler_run_result. status . success ( ) {
801803 self . fatal_proc_rec ( "compilation failed!" , & compiler_run_result) ;
802804 }
@@ -1028,7 +1030,7 @@ impl<'test> TestCx<'test> {
10281030 fn run_debuginfo_lldb_test_no_opt ( & self ) {
10291031 // compile test file (it should have 'compile-flags:-g' in the header)
10301032 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 ) ;
10321034 if !compile_result. status . success ( ) {
10331035 self . fatal_proc_rec ( "compilation failed!" , & compile_result) ;
10341036 }
@@ -1453,21 +1455,21 @@ impl<'test> TestCx<'test> {
14531455 }
14541456 }
14551457
1456- fn should_emit_metadata ( & self , pm : Option < PassMode > ) -> EmitMetadata {
1458+ fn should_emit_metadata ( & self , pm : Option < PassMode > ) -> Emit {
14571459 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 ,
14601462 }
14611463 }
14621464
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 ( ) )
14651467 }
14661468
14671469 fn compile_test_general (
14681470 & self ,
14691471 will_execute : WillExecute ,
1470- emit_metadata : EmitMetadata ,
1472+ emit : Emit ,
14711473 local_pm : Option < PassMode > ,
14721474 ) -> ProcRes {
14731475 // Only use `make_exe_name` when the test ends up being executed.
@@ -1502,7 +1504,7 @@ impl<'test> TestCx<'test> {
15021504 let rustc = self . make_compile_args (
15031505 & self . testpaths . file ,
15041506 output_file,
1505- emit_metadata ,
1507+ emit ,
15061508 allow_unused,
15071509 LinkToAux :: Yes ,
15081510 ) ;
@@ -1735,7 +1737,7 @@ impl<'test> TestCx<'test> {
17351737 let mut aux_rustc = aux_cx. make_compile_args (
17361738 input_file,
17371739 aux_output,
1738- EmitMetadata :: No ,
1740+ Emit :: None ,
17391741 AllowUnused :: No ,
17401742 LinkToAux :: No ,
17411743 ) ;
@@ -1875,7 +1877,7 @@ impl<'test> TestCx<'test> {
18751877 & self ,
18761878 input_file : & Path ,
18771879 output_file : TargetLocation ,
1878- emit_metadata : EmitMetadata ,
1880+ emit : Emit ,
18791881 allow_unused : AllowUnused ,
18801882 link_to_aux : LinkToAux ,
18811883 ) -> Command {
@@ -1992,8 +1994,18 @@ impl<'test> TestCx<'test> {
19921994 }
19931995 }
19941996
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+ }
19972009 }
19982010
19992011 if !is_rustdoc {
@@ -2262,14 +2274,13 @@ impl<'test> TestCx<'test> {
22622274 fn compile_test_and_save_ir ( & self ) -> ProcRes {
22632275 let output_file = TargetLocation :: ThisDirectory ( self . output_base_dir ( ) ) ;
22642276 let input_file = & self . testpaths . file ;
2265- let mut rustc = self . make_compile_args (
2277+ let rustc = self . make_compile_args (
22662278 input_file,
22672279 output_file,
2268- EmitMetadata :: No ,
2280+ Emit :: LlvmIr ,
22692281 AllowUnused :: No ,
22702282 LinkToAux :: Yes ,
22712283 ) ;
2272- rustc. arg ( "--emit=llvm-ir" ) ;
22732284
22742285 self . compose_and_run_compiler ( rustc, None )
22752286 }
@@ -2281,17 +2292,11 @@ impl<'test> TestCx<'test> {
22812292
22822293 let output_file = TargetLocation :: ThisFile ( output_path. clone ( ) ) ;
22832294 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- ) ;
22912295
2296+ let mut emit = Emit :: None ;
22922297 match self . props . assembly_output . as_ref ( ) . map ( AsRef :: as_ref) {
22932298 Some ( "emit-asm" ) => {
2294- rustc . arg ( "-- emit=asm" ) ;
2299+ emit = Emit :: Asm ;
22952300 }
22962301
22972302 Some ( "ptx-linker" ) => {
@@ -2302,6 +2307,9 @@ impl<'test> TestCx<'test> {
23022307 None => self . fatal ( "missing 'assembly-output' header" ) ,
23032308 }
23042309
2310+ let rustc =
2311+ self . make_compile_args ( input_file, output_file, emit, AllowUnused :: No , LinkToAux :: Yes ) ;
2312+
23052313 ( self . compose_and_run_compiler ( rustc, None ) , output_path)
23062314 }
23072315
@@ -2426,7 +2434,7 @@ impl<'test> TestCx<'test> {
24262434 let mut rustc = new_rustdoc. make_compile_args (
24272435 & new_rustdoc. testpaths . file ,
24282436 output_file,
2429- EmitMetadata :: No ,
2437+ Emit :: None ,
24302438 AllowUnused :: Yes ,
24312439 LinkToAux :: Yes ,
24322440 ) ;
@@ -2702,7 +2710,7 @@ impl<'test> TestCx<'test> {
27022710 fn run_codegen_units_test ( & self ) {
27032711 assert ! ( self . revision. is_none( ) , "revisions not relevant here" ) ;
27042712
2705- let proc_res = self . compile_test ( WillExecute :: No , EmitMetadata :: No ) ;
2713+ let proc_res = self . compile_test ( WillExecute :: No , Emit :: None ) ;
27062714
27072715 if !proc_res. status . success ( ) {
27082716 self . fatal_proc_rec ( "compilation failed!" , & proc_res) ;
@@ -3215,7 +3223,7 @@ impl<'test> TestCx<'test> {
32153223 if let Some ( FailMode :: Build ) = self . props . fail_mode {
32163224 // Make sure a build-fail test cannot fail due to failing analysis (e.g. typeck).
32173225 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) ;
32193227 self . check_if_test_should_compile ( & proc_res, pm) ;
32203228 }
32213229
0 commit comments