Skip to content

Commit d0feade

Browse files
committed
add '-A unused' before user-configured compile_flags
1 parent 246a708 commit d0feade

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

src/runtest.rs

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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);
@@ -1471,6 +1471,13 @@ actual:\n\
14711471
rustc.arg(format!("-Clinker={}", linker));
14721472
}
14731473

1474+
match allow_unused {
1475+
AllowUnused::Yes => {
1476+
rustc.args(&["-A", "unused"]);
1477+
}
1478+
AllowUnused::No => {}
1479+
}
1480+
14741481
rustc.args(&self.props.compile_flags);
14751482

14761483
rustc
@@ -1699,7 +1706,7 @@ actual:\n\
16991706

17001707
let output_file = TargetLocation::ThisDirectory(
17011708
self.output_base_name().parent().unwrap().to_path_buf());
1702-
let mut rustc = self.make_compile_args(&self.testpaths.file, output_file);
1709+
let mut rustc = self.make_compile_args(&self.testpaths.file, output_file, AllowUnused::No);
17031710
rustc.arg("-L").arg(aux_dir)
17041711
.arg("--emit=llvm-ir");
17051712

@@ -2343,6 +2350,7 @@ actual:\n\
23432350
let mut rustc = self.make_compile_args(
23442351
&self.testpaths.file.with_extension(UI_FIXED),
23452352
TargetLocation::ThisFile(self.make_exe_name()),
2353+
AllowUnused::No,
23462354
);
23472355
rustc.arg("-L").arg(&self.aux_output_dir_name());
23482356
let res = self.compose_and_run_compiler(rustc, None);
@@ -2667,6 +2675,11 @@ enum ExpectedLine<T: AsRef<str>> {
26672675
Text(T)
26682676
}
26692677

2678+
enum AllowUnused {
2679+
Yes,
2680+
No,
2681+
}
2682+
26702683
impl<T> fmt::Debug for ExpectedLine<T>
26712684
where
26722685
T: AsRef<str> + fmt::Debug

0 commit comments

Comments
 (0)