From edbb86264d0953cc9bba5a5cace01e94cf45baf2 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Tue, 21 Apr 2026 16:56:28 +1000 Subject: [PATCH] Add support for `cpass` incremental revisions --- src/doc/rustc-dev-guide/src/tests/compiletest.md | 9 +++++---- src/tools/compiletest/src/runtest.rs | 7 +++++-- src/tools/compiletest/src/runtest/incremental.rs | 12 ++++++++++-- tests/incremental/hashes/delayed_lints.rs | 13 ++++++------- tests/incremental/no_mangle.rs | 3 +-- tests/incremental/track-deps-in-new-solver.rs | 8 +++----- 6 files changed, 30 insertions(+), 22 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/tests/compiletest.md b/src/doc/rustc-dev-guide/src/tests/compiletest.md index beef777ccc33..ef30869ac762 100644 --- a/src/doc/rustc-dev-guide/src/tests/compiletest.md +++ b/src/doc/rustc-dev-guide/src/tests/compiletest.md @@ -156,11 +156,12 @@ series of steps. Compiletest starts with an empty directory with the `-C incremental` flag, and then runs the compiler for each revision, reusing the incremental results from previous steps. -The revisions should start with: +Each revision name must start with one of: -* `bfail` — the test should fail to compile -* `bpass` — the test should compile successully -* `rpass` — the test should compile and run successfully +* `cpass` - the test must compile successfully (check build, no codegen) +* `bfail` — the test must fail to compile (full build, with codegen) +* `bpass` — the test must compile successully (full build, with codegen) +* `rpass` — the test must compile and run successfully To make the revisions unique, you should add a suffix like `rpass1` and `rpass2`. diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index be65aea9b47e..6c9fb9d67e7d 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -327,12 +327,15 @@ fn should_compile_successfully(&self, pm: Option) -> bool { TestMode::Incremental => { let revision = self.revision.expect("incremental tests require a list of revisions"); - if revision.starts_with("bpass") || revision.starts_with("rpass") { + if revision.starts_with("cpass") + || revision.starts_with("bpass") + || revision.starts_with("rpass") + { true } else if revision.starts_with("bfail") { pm.is_some() } else { - panic!("revision name must begin with `bfail`, `bpass`, or `rpass`"); + panic!("revision name must begin with `cpass`, `bfail`, `bpass`, or `rpass`"); } } mode => panic!("unimplemented for mode {:?}", mode), diff --git a/src/tools/compiletest/src/runtest/incremental.rs b/src/tools/compiletest/src/runtest/incremental.rs index 120c35d97307..85e0c89a8d01 100644 --- a/src/tools/compiletest/src/runtest/incremental.rs +++ b/src/tools/compiletest/src/runtest/incremental.rs @@ -1,4 +1,4 @@ -use super::{FailMode, ProcRes, TestCx, WillExecute}; +use super::{Emit, FailMode, PassMode, ProcRes, TestCx, WillExecute}; impl TestCx<'_> { pub(super) fn run_incremental_test(&self) { @@ -31,7 +31,9 @@ pub(super) fn run_incremental_test(&self) { write!(self.stdout, "revision={:?} props={:#?}", revision, self.props); } - if revision.starts_with("bpass") { + if revision.starts_with("cpass") { + self.run_cpass_test(); + } else if revision.starts_with("bpass") { self.run_bpass_test(); } else if revision.starts_with("rpass") { self.run_rpass_test(); @@ -42,6 +44,12 @@ pub(super) fn run_incremental_test(&self) { } } + fn run_cpass_test(&self) { + let proc_res = self.compile_test(WillExecute::No, Emit::Metadata); + self.check_if_test_should_compile(None, Some(PassMode::Check), &proc_res); + self.check_compiler_output_for_incr(&proc_res); + } + fn run_bpass_test(&self) { let emit_metadata = self.should_emit_metadata(self.pass_mode()); let proc_res = self.compile_test(WillExecute::No, emit_metadata); diff --git a/tests/incremental/hashes/delayed_lints.rs b/tests/incremental/hashes/delayed_lints.rs index a487922494d9..46c7b5b33ac7 100644 --- a/tests/incremental/hashes/delayed_lints.rs +++ b/tests/incremental/hashes/delayed_lints.rs @@ -2,8 +2,7 @@ // Emitting these lints is delayed until after ast lowering. // This test tests that the delayed hints are correctly hashed for incremental. -//@ check-pass -//@ revisions: bfail1 bfail2 bfail3 +//@ revisions: cpass1 cpass2 cpass3 //@ compile-flags: -Z query-dep-graph -O -Zincremental-ignore-spans //@ ignore-backends: gcc #![feature(rustc_attrs)] @@ -15,13 +14,13 @@ // Between revision 1 and 2, the only thing we change is that we add "test = 2" // This will emit an extra delayed lint, but it will not change the HIR hash. // We check that even tho the HIR hash didn't change, the extra lint is emitted -#[cfg_attr(bfail1, doc(hidden))] -#[cfg_attr(not(bfail1), doc(hidden, test = 2))] -//[bfail2,bfail3]~^ WARN `#[doc(test(...)]` takes a list of attributes [invalid_doc_attributes] +#[cfg_attr(cpass1, doc(hidden))] +#[cfg_attr(not(cpass1), doc(hidden, test = 2))] +//[cpass2,cpass3]~^ WARN `#[doc(test(...)]` takes a list of attributes [invalid_doc_attributes] // The HIR hash should not change between revisions, for this test to be representative -#[rustc_clean(cfg="bfail2")] -#[rustc_clean(cfg="bfail3")] +#[rustc_clean(cfg="cpass2")] +#[rustc_clean(cfg="cpass3")] trait Test {} fn main() {} diff --git a/tests/incremental/no_mangle.rs b/tests/incremental/no_mangle.rs index 1faab3ca69df..fbb3cb1ef545 100644 --- a/tests/incremental/no_mangle.rs +++ b/tests/incremental/no_mangle.rs @@ -1,5 +1,4 @@ -//@ revisions: bfail1 bfail2 -//@ check-pass +//@ revisions: cpass1 cpass2 //@ compile-flags: --crate-type cdylib //@ needs-crate-type: cdylib diff --git a/tests/incremental/track-deps-in-new-solver.rs b/tests/incremental/track-deps-in-new-solver.rs index d224d9f4d87f..4b4d733e1d92 100644 --- a/tests/incremental/track-deps-in-new-solver.rs +++ b/tests/incremental/track-deps-in-new-solver.rs @@ -1,7 +1,5 @@ -//@ revisions: bfail1 bfail2 - +//@ revisions: cpass1 cpass2 //@ compile-flags: -Znext-solver -//@ check-pass #![allow(dead_code)] @@ -18,10 +16,10 @@ fn poll() -> Self::Error { } } -#[cfg(bfail1)] +#[cfg(cpass1)] pub struct Error(()); -#[cfg(bfail2)] +#[cfg(cpass2)] pub struct Error(); fn main() {}