Skip to content

Commit 333f033

Browse files
Rollup merge of rust-lang#155641 - Zalathar:no-run-mir-opt, r=jieyouxu
Remove non-working code for "running" mir-opt tests Tests in `tests/mir-opt` always use `--emit=mir`, so the compiler doesn't even produce an executable. Attempting to "run" these tests (e.g. with `./x test mir-opt --pass=run`) therefore fails when the OS notices that a MIR text file is not executable. --- The second commit performs some semi-related cleanup. r? jieyouxu
2 parents 610bfad + 1a3c6b4 commit 333f033

3 files changed

Lines changed: 12 additions & 36 deletions

File tree

src/tools/compiletest/src/runtest.rs

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -295,14 +295,9 @@ impl<'test> TestCx<'test> {
295295

296296
fn should_run(&self, pm: Option<PassMode>) -> WillExecute {
297297
let test_should_run = match self.config.mode {
298-
TestMode::Ui
299-
if pm == Some(PassMode::Run)
300-
|| matches!(self.props.fail_mode, Some(FailMode::Run(_))) =>
301-
{
302-
true
298+
TestMode::Ui => {
299+
pm == Some(PassMode::Run) || matches!(self.props.fail_mode, Some(FailMode::Run(_)))
303300
}
304-
TestMode::MirOpt if pm == Some(PassMode::Run) => true,
305-
TestMode::Ui | TestMode::MirOpt => false,
306301
mode => panic!("unimplemented for mode {:?}", mode),
307302
};
308303
if test_should_run { self.run_if_enabled() } else { WillExecute::No }
@@ -314,7 +309,7 @@ impl<'test> TestCx<'test> {
314309

315310
fn should_run_successfully(&self, pm: Option<PassMode>) -> bool {
316311
match self.config.mode {
317-
TestMode::Ui | TestMode::MirOpt => pm == Some(PassMode::Run),
312+
TestMode::Ui => pm == Some(PassMode::Run),
318313
mode => panic!("unimplemented for mode {:?}", mode),
319314
}
320315
}
@@ -935,23 +930,13 @@ impl<'test> TestCx<'test> {
935930
}
936931

937932
fn compile_test(&self, will_execute: WillExecute, emit: Emit) -> ProcRes {
938-
self.compile_test_general(will_execute, emit, self.props.local_pass_mode(), Vec::new())
939-
}
940-
941-
fn compile_test_with_passes(
942-
&self,
943-
will_execute: WillExecute,
944-
emit: Emit,
945-
passes: Vec<String>,
946-
) -> ProcRes {
947-
self.compile_test_general(will_execute, emit, self.props.local_pass_mode(), passes)
933+
self.compile_test_general(will_execute, emit, Vec::new())
948934
}
949935

950936
fn compile_test_general(
951937
&self,
952938
will_execute: WillExecute,
953939
emit: Emit,
954-
local_pm: Option<PassMode>,
955940
passes: Vec<String>,
956941
) -> ProcRes {
957942
let compiler_kind = self.compiler_kind_for_non_aux();
@@ -975,7 +960,7 @@ impl<'test> TestCx<'test> {
975960
// Note that we use the local pass mode here as we don't want
976961
// to set unused to allow if we've overridden the pass mode
977962
// via command line flags.
978-
&& local_pm != Some(PassMode::Run)
963+
&& self.props.local_pass_mode() != Some(PassMode::Run)
979964
{
980965
AllowUnused::Yes
981966
} else {

src/tools/compiletest/src/runtest/mir_opt.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ use crate::runtest::compute_diff::write_diff;
1010

1111
impl TestCx<'_> {
1212
pub(super) fn run_mir_opt_test(&self) {
13-
let pm = self.pass_mode();
14-
let should_run = self.should_run(pm);
15-
1613
let mut test_info = files_for_miropt_test(
1714
&self.testpaths.file.as_std_path(),
1815
self.config.get_pointer_width(),
@@ -21,19 +18,11 @@ impl TestCx<'_> {
2118

2219
let passes = std::mem::take(&mut test_info.passes);
2320

24-
let proc_res = self.compile_test_with_passes(should_run, Emit::Mir, passes);
21+
let proc_res = self.compile_test_general(WillExecute::No, Emit::Mir, passes);
2522
if !proc_res.status.success() {
2623
self.fatal_proc_rec("compilation failed!", &proc_res);
2724
}
2825
self.check_mir_dump(test_info);
29-
30-
if let WillExecute::Yes = should_run {
31-
let proc_res = self.exec_compiled_test();
32-
33-
if !proc_res.status.success() {
34-
self.fatal_proc_rec("test run failed!", &proc_res);
35-
}
36-
}
3726
}
3827

3928
fn check_mir_dump(&self, test_info: MiroptTest) {

src/tools/compiletest/src/runtest/ui.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ impl TestCx<'_> {
1515
pub(super) fn run_ui_test(&self) {
1616
if let Some(FailMode::Build) = self.props.fail_mode {
1717
// Make sure a build-fail test cannot fail due to failing analysis (e.g. typeck).
18-
let pm = Some(PassMode::Check);
19-
let proc_res =
20-
self.compile_test_general(WillExecute::No, Emit::Metadata, pm, Vec::new());
21-
self.check_if_test_should_compile(self.props.fail_mode, pm, &proc_res);
18+
let proc_res = self.compile_test(WillExecute::No, Emit::Metadata);
19+
self.check_if_test_should_compile(
20+
self.props.fail_mode,
21+
Some(PassMode::Check),
22+
&proc_res,
23+
);
2224
}
2325

2426
let pm = self.pass_mode();

0 commit comments

Comments
 (0)