Skip to content

Commit 3441779

Browse files
committed
tools/compiletest: fix argument ordering for allowing unused in ui & compile-fail tests
1 parent 51021b1 commit 3441779

File tree

1 file changed

+31
-11
lines changed

1 file changed

+31
-11
lines changed

src/tools/compiletest/src/runtest.rs

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,11 +1478,7 @@ impl<'test> TestCx<'test> {
14781478
WillExecute::No => TargetLocation::ThisDirectory(self.output_base_dir()),
14791479
};
14801480

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 {
14861482
CompileFail | Ui => {
14871483
// compile-fail and ui tests tend to have tons of unused code as
14881484
// it's just testing various pieces of the compile, but we don't
@@ -1495,11 +1491,18 @@ impl<'test> TestCx<'test> {
14951491
// via command line flags.
14961492
&& local_pm != Some(PassMode::Run)
14971493
{
1498-
rustc.args(&["-A", "unused"]);
1494+
AllowUnused::Yes
1495+
} else {
1496+
AllowUnused::No
14991497
}
15001498
}
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());
15031506

15041507
self.compose_and_run_compiler(rustc, None)
15051508
}
@@ -1710,7 +1713,8 @@ impl<'test> TestCx<'test> {
17101713
// Create the directory for the stdout/stderr files.
17111714
create_dir_all(aux_cx.output_base_dir()).unwrap();
17121715
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);
17141718

17151719
let (dylib, crate_type) = if aux_props.no_prefer_dynamic {
17161720
(true, None)
@@ -1819,6 +1823,7 @@ impl<'test> TestCx<'test> {
18191823
input_file: &Path,
18201824
output_file: TargetLocation,
18211825
emit_metadata: EmitMetadata,
1826+
allow_unused: AllowUnused,
18221827
) -> Command {
18231828
let is_rustdoc = self.is_rustdoc();
18241829
let mut rustc = if !is_rustdoc {
@@ -1951,6 +1956,13 @@ impl<'test> TestCx<'test> {
19511956
rustc.arg("-Ctarget-feature=-crt-static");
19521957
}
19531958

1959+
match allow_unused {
1960+
AllowUnused::Yes => {
1961+
rustc.args(&["-A", "unused"]);
1962+
}
1963+
AllowUnused::No => {}
1964+
}
1965+
19541966
rustc.args(&self.props.compile_flags);
19551967

19561968
rustc
@@ -2134,7 +2146,8 @@ impl<'test> TestCx<'test> {
21342146

21352147
let output_file = TargetLocation::ThisDirectory(self.output_base_dir());
21362148
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);
21382151
rustc.arg("-L").arg(aux_dir).arg("--emit=llvm-ir");
21392152

21402153
self.compose_and_run_compiler(rustc, None)
@@ -2147,7 +2160,8 @@ impl<'test> TestCx<'test> {
21472160

21482161
let output_file = TargetLocation::ThisFile(output_path.clone());
21492162
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);
21512165

21522166
rustc.arg("-L").arg(self.aux_output_dir_name());
21532167

@@ -2999,6 +3013,7 @@ impl<'test> TestCx<'test> {
29993013
&self.testpaths.file.with_extension(UI_FIXED),
30003014
TargetLocation::ThisFile(self.make_exe_name()),
30013015
emit_metadata,
3016+
AllowUnused::No,
30023017
);
30033018
rustc.arg("-L").arg(&self.aux_output_dir_name());
30043019
let res = self.compose_and_run_compiler(rustc, None);
@@ -3486,6 +3501,11 @@ enum ExpectedLine<T: AsRef<str>> {
34863501
Text(T),
34873502
}
34883503

3504+
enum AllowUnused {
3505+
Yes,
3506+
No,
3507+
}
3508+
34893509
impl<T> fmt::Debug for ExpectedLine<T>
34903510
where
34913511
T: AsRef<str> + fmt::Debug,

0 commit comments

Comments
 (0)