@@ -1478,11 +1478,7 @@ impl<'test> TestCx<'test> {
1478
1478
WillExecute :: No => TargetLocation :: ThisDirectory ( self . output_base_dir ( ) ) ,
1479
1479
} ;
1480
1480
1481
- let mut rustc = self . make_compile_args ( & self . testpaths . file , output_file, emit_metadata) ;
1482
-
1483
- rustc. arg ( "-L" ) . arg ( & self . aux_output_dir_name ( ) ) ;
1484
-
1485
- match self . config . mode {
1481
+ let allow_unused = match self . config . mode {
1486
1482
CompileFail | Ui => {
1487
1483
// compile-fail and ui tests tend to have tons of unused code as
1488
1484
// it's just testing various pieces of the compile, but we don't
@@ -1495,11 +1491,18 @@ impl<'test> TestCx<'test> {
1495
1491
// via command line flags.
1496
1492
&& local_pm != Some ( PassMode :: Run )
1497
1493
{
1498
- rustc. args ( & [ "-A" , "unused" ] ) ;
1494
+ AllowUnused :: Yes
1495
+ } else {
1496
+ AllowUnused :: No
1499
1497
}
1500
1498
}
1501
- _ => { }
1502
- }
1499
+ _ => AllowUnused :: No ,
1500
+ } ;
1501
+
1502
+ let mut rustc =
1503
+ self . make_compile_args ( & self . testpaths . file , output_file, emit_metadata, allow_unused) ;
1504
+
1505
+ rustc. arg ( "-L" ) . arg ( & self . aux_output_dir_name ( ) ) ;
1503
1506
1504
1507
self . compose_and_run_compiler ( rustc, None )
1505
1508
}
@@ -1710,7 +1713,8 @@ impl<'test> TestCx<'test> {
1710
1713
// Create the directory for the stdout/stderr files.
1711
1714
create_dir_all ( aux_cx. output_base_dir ( ) ) . unwrap ( ) ;
1712
1715
let input_file = & aux_testpaths. file ;
1713
- let mut aux_rustc = aux_cx. make_compile_args ( input_file, aux_output, EmitMetadata :: No ) ;
1716
+ let mut aux_rustc =
1717
+ aux_cx. make_compile_args ( input_file, aux_output, EmitMetadata :: No , AllowUnused :: No ) ;
1714
1718
1715
1719
let ( dylib, crate_type) = if aux_props. no_prefer_dynamic {
1716
1720
( true , None )
@@ -1819,6 +1823,7 @@ impl<'test> TestCx<'test> {
1819
1823
input_file : & Path ,
1820
1824
output_file : TargetLocation ,
1821
1825
emit_metadata : EmitMetadata ,
1826
+ allow_unused : AllowUnused ,
1822
1827
) -> Command {
1823
1828
let is_rustdoc = self . is_rustdoc ( ) ;
1824
1829
let mut rustc = if !is_rustdoc {
@@ -1951,6 +1956,13 @@ impl<'test> TestCx<'test> {
1951
1956
rustc. arg ( "-Ctarget-feature=-crt-static" ) ;
1952
1957
}
1953
1958
1959
+ match allow_unused {
1960
+ AllowUnused :: Yes => {
1961
+ rustc. args ( & [ "-A" , "unused" ] ) ;
1962
+ }
1963
+ AllowUnused :: No => { }
1964
+ }
1965
+
1954
1966
rustc. args ( & self . props . compile_flags ) ;
1955
1967
1956
1968
rustc
@@ -2134,7 +2146,8 @@ impl<'test> TestCx<'test> {
2134
2146
2135
2147
let output_file = TargetLocation :: ThisDirectory ( self . output_base_dir ( ) ) ;
2136
2148
let input_file = & self . testpaths . file ;
2137
- let mut rustc = self . make_compile_args ( input_file, output_file, EmitMetadata :: No ) ;
2149
+ let mut rustc =
2150
+ self . make_compile_args ( input_file, output_file, EmitMetadata :: No , AllowUnused :: No ) ;
2138
2151
rustc. arg ( "-L" ) . arg ( aux_dir) . arg ( "--emit=llvm-ir" ) ;
2139
2152
2140
2153
self . compose_and_run_compiler ( rustc, None )
@@ -2147,7 +2160,8 @@ impl<'test> TestCx<'test> {
2147
2160
2148
2161
let output_file = TargetLocation :: ThisFile ( output_path. clone ( ) ) ;
2149
2162
let input_file = & self . testpaths . file ;
2150
- let mut rustc = self . make_compile_args ( input_file, output_file, EmitMetadata :: No ) ;
2163
+ let mut rustc =
2164
+ self . make_compile_args ( input_file, output_file, EmitMetadata :: No , AllowUnused :: No ) ;
2151
2165
2152
2166
rustc. arg ( "-L" ) . arg ( self . aux_output_dir_name ( ) ) ;
2153
2167
@@ -2999,6 +3013,7 @@ impl<'test> TestCx<'test> {
2999
3013
& self . testpaths . file . with_extension ( UI_FIXED ) ,
3000
3014
TargetLocation :: ThisFile ( self . make_exe_name ( ) ) ,
3001
3015
emit_metadata,
3016
+ AllowUnused :: No ,
3002
3017
) ;
3003
3018
rustc. arg ( "-L" ) . arg ( & self . aux_output_dir_name ( ) ) ;
3004
3019
let res = self . compose_and_run_compiler ( rustc, None ) ;
@@ -3486,6 +3501,11 @@ enum ExpectedLine<T: AsRef<str>> {
3486
3501
Text ( T ) ,
3487
3502
}
3488
3503
3504
+ enum AllowUnused {
3505
+ Yes ,
3506
+ No ,
3507
+ }
3508
+
3489
3509
impl < T > fmt:: Debug for ExpectedLine < T >
3490
3510
where
3491
3511
T : AsRef < str > + fmt:: Debug ,
0 commit comments