@@ -1112,22 +1112,22 @@ actual:\n\
1112
1112
}
1113
1113
1114
1114
fn compile_test ( & self ) -> ProcRes {
1115
- let mut rustc = self . make_compile_args (
1116
- & self . testpaths . file , TargetLocation :: ThisFile ( self . make_exe_name ( ) ) ) ;
1117
-
1118
- rustc. arg ( "-L" ) . arg ( & self . aux_output_dir_name ( ) ) ;
1119
-
1120
- match self . config . mode {
1115
+ let allow_unused = match self . config . mode {
1121
1116
CompileFail | Ui => {
1122
1117
// compile-fail and ui tests tend to have tons of unused code as
1123
1118
// it's just testing various pieces of the compile, but we don't
1124
1119
// want to actually assert warnings about all this code. Instead
1125
1120
// let's just ignore unused code warnings by defaults and tests
1126
1121
// can turn it back on if needed.
1127
- rustc . args ( & [ "-A" , "unused" ] ) ;
1122
+ AllowUnused :: Yes
1128
1123
}
1129
- _ => { }
1130
- }
1124
+ _ => AllowUnused :: No
1125
+ } ;
1126
+
1127
+ let mut rustc = self . make_compile_args (
1128
+ & self . testpaths . file , TargetLocation :: ThisFile ( self . make_exe_name ( ) ) , allow_unused) ;
1129
+
1130
+ rustc. arg ( "-L" ) . arg ( & self . aux_output_dir_name ( ) ) ;
1131
1131
1132
1132
self . compose_and_run_compiler ( rustc, None )
1133
1133
}
@@ -1271,7 +1271,7 @@ actual:\n\
1271
1271
testpaths : & aux_testpaths,
1272
1272
revision : self . revision
1273
1273
} ;
1274
- let mut aux_rustc = aux_cx. make_compile_args ( & aux_testpaths. file , aux_output) ;
1274
+ let mut aux_rustc = aux_cx. make_compile_args ( & aux_testpaths. file , aux_output, AllowUnused :: No ) ;
1275
1275
1276
1276
let crate_type = if aux_props. no_prefer_dynamic {
1277
1277
None
@@ -1367,7 +1367,7 @@ actual:\n\
1367
1367
result
1368
1368
}
1369
1369
1370
- fn make_compile_args ( & self , input_file : & Path , output_file : TargetLocation ) -> Command {
1370
+ fn make_compile_args ( & self , input_file : & Path , output_file : TargetLocation , allow_unused : AllowUnused ) -> Command {
1371
1371
let mut rustc = Command :: new ( & self . config . rustc_path ) ;
1372
1372
rustc. arg ( input_file)
1373
1373
. arg ( "-L" ) . arg ( & self . config . build_base ) ;
@@ -1462,6 +1462,12 @@ actual:\n\
1462
1462
}
1463
1463
}
1464
1464
1465
+ // Add `-A unused` before `config` flags and in-test (`props`) flags, so that they can
1466
+ // overwrite this.
1467
+ if let AllowUnused :: Yes = allow_unused {
1468
+ rustc. args ( & [ "-A" , "unused" ] ) ;
1469
+ }
1470
+
1465
1471
if self . props . force_host {
1466
1472
rustc. args ( self . split_maybe_args ( & self . config . host_rustcflags ) ) ;
1467
1473
} else {
@@ -1699,7 +1705,7 @@ actual:\n\
1699
1705
1700
1706
let output_file = TargetLocation :: ThisDirectory (
1701
1707
self . output_base_name ( ) . parent ( ) . unwrap ( ) . to_path_buf ( ) ) ;
1702
- let mut rustc = self . make_compile_args ( & self . testpaths . file , output_file) ;
1708
+ let mut rustc = self . make_compile_args ( & self . testpaths . file , output_file, AllowUnused :: No ) ;
1703
1709
rustc. arg ( "-L" ) . arg ( aux_dir)
1704
1710
. arg ( "--emit=llvm-ir" ) ;
1705
1711
@@ -2343,6 +2349,7 @@ actual:\n\
2343
2349
let mut rustc = self . make_compile_args (
2344
2350
& self . testpaths . file . with_extension ( UI_FIXED ) ,
2345
2351
TargetLocation :: ThisFile ( self . make_exe_name ( ) ) ,
2352
+ AllowUnused :: No ,
2346
2353
) ;
2347
2354
rustc. arg ( "-L" ) . arg ( & self . aux_output_dir_name ( ) ) ;
2348
2355
let res = self . compose_and_run_compiler ( rustc, None ) ;
@@ -2667,6 +2674,11 @@ enum ExpectedLine<T: AsRef<str>> {
2667
2674
Text ( T )
2668
2675
}
2669
2676
2677
+ enum AllowUnused {
2678
+ Yes ,
2679
+ No ,
2680
+ }
2681
+
2670
2682
impl < T > fmt:: Debug for ExpectedLine < T >
2671
2683
where
2672
2684
T : AsRef < str > + fmt:: Debug
0 commit comments