@@ -1112,22 +1112,22 @@ actual:\n\
11121112 }
11131113
11141114 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 {
11211116 CompileFail | Ui => {
11221117 // compile-fail and ui tests tend to have tons of unused code as
11231118 // it's just testing various pieces of the compile, but we don't
11241119 // want to actually assert warnings about all this code. Instead
11251120 // let's just ignore unused code warnings by defaults and tests
11261121 // can turn it back on if needed.
1127- rustc . args ( & [ "-A" , "unused" ] ) ;
1122+ AllowUnused :: Yes
11281123 }
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 ( ) ) ;
11311131
11321132 self . compose_and_run_compiler ( rustc, None )
11331133 }
@@ -1271,7 +1271,7 @@ actual:\n\
12711271 testpaths : & aux_testpaths,
12721272 revision : self . revision
12731273 } ;
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 ) ;
12751275
12761276 let crate_type = if aux_props. no_prefer_dynamic {
12771277 None
@@ -1367,7 +1367,7 @@ actual:\n\
13671367 result
13681368 }
13691369
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 {
13711371 let mut rustc = Command :: new ( & self . config . rustc_path ) ;
13721372 rustc. arg ( input_file)
13731373 . arg ( "-L" ) . arg ( & self . config . build_base ) ;
@@ -1462,6 +1462,12 @@ actual:\n\
14621462 }
14631463 }
14641464
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+
14651471 if self . props . force_host {
14661472 rustc. args ( self . split_maybe_args ( & self . config . host_rustcflags ) ) ;
14671473 } else {
@@ -1699,7 +1705,7 @@ actual:\n\
16991705
17001706 let output_file = TargetLocation :: ThisDirectory (
17011707 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 ) ;
17031709 rustc. arg ( "-L" ) . arg ( aux_dir)
17041710 . arg ( "--emit=llvm-ir" ) ;
17051711
@@ -2343,6 +2349,7 @@ actual:\n\
23432349 let mut rustc = self . make_compile_args (
23442350 & self . testpaths . file . with_extension ( UI_FIXED ) ,
23452351 TargetLocation :: ThisFile ( self . make_exe_name ( ) ) ,
2352+ AllowUnused :: No ,
23462353 ) ;
23472354 rustc. arg ( "-L" ) . arg ( & self . aux_output_dir_name ( ) ) ;
23482355 let res = self . compose_and_run_compiler ( rustc, None ) ;
@@ -2667,6 +2674,11 @@ enum ExpectedLine<T: AsRef<str>> {
26672674 Text ( T )
26682675}
26692676
2677+ enum AllowUnused {
2678+ Yes ,
2679+ No ,
2680+ }
2681+
26702682impl < T > fmt:: Debug for ExpectedLine < T >
26712683where
26722684 T : AsRef < str > + fmt:: Debug
0 commit comments