From 5bc9308471ce452003bfebd97db401ae145bffda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Wed, 27 Aug 2025 11:38:39 +0200 Subject: [PATCH] Do not run `lint-docs` tests in stage 1 `x test` by default --- src/bootstrap/src/core/build_steps/test.rs | 20 +++++++++----------- src/bootstrap/src/core/builder/tests.rs | 4 +--- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 1786e8d17b6e..95be5360b0bb 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -2693,7 +2693,7 @@ fn markdown_test(builder: &Builder<'_>, compiler: Compiler, markdown: &Path) -> /// which have their own separate test steps.) #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct CrateLibrustc { - /// The compiler that will *build* rustc in test mode. + /// The compiler that will run unit tests and doctests on the in-tree rustc source. build_compiler: Compiler, target: TargetSelection, crates: Vec, @@ -3429,24 +3429,22 @@ impl Step for LintDocs { const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - run.path("src/tools/lint-docs") + let stage = run.builder.top_stage; + // Lint docs tests might not work with stage 1, so do not run this test by default in + // `x test` below stage 2. + run.path("src/tools/lint-docs").default_condition(stage > 1) } fn make_run(run: RunConfig<'_>) { - // Bump the stage to 2, because the rustc book requires an in-tree compiler. - // At the same time, since this step is enabled by default, we don't want `x test` to fail - // in stage 1. - let stage = if run.builder.config.is_explicit_stage() || run.builder.top_stage >= 2 { - run.builder.top_stage - } else { - 2 - }; + if run.builder.top_stage < 2 { + eprintln!("WARNING: lint-docs tests might not work below stage 2"); + } run.builder.ensure(LintDocs { build_compiler: prepare_doc_compiler( run.builder, run.builder.config.host_target, - stage, + run.builder.top_stage, ), target: run.target, }); diff --git a/src/bootstrap/src/core/builder/tests.rs b/src/bootstrap/src/core/builder/tests.rs index f14c897cab49..43e67756e742 100644 --- a/src/bootstrap/src/core/builder/tests.rs +++ b/src/bootstrap/src/core/builder/tests.rs @@ -2111,8 +2111,6 @@ mod snapshot { [test] link-check [test] tier-check [test] rustc 0 -> rust-analyzer 1 - [doc] rustc (book) - [test] rustc 1 -> lint-docs 2 [build] rustc 0 -> RustdocTheme 1 [test] rustdoc-theme 1 [test] RustdocUi @@ -2175,7 +2173,7 @@ mod snapshot { [doc] book/second-edition (book) [doc] book/2018-edition (book) [doc] rustc 1 -> standalone 2 - [doc] rustc 2 -> std 2 crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] + [doc] rustc 1 -> std 1 crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind] [build] rustc 1 -> error-index 2 [doc] rustc 1 -> error-index 2 [doc] nomicon (book)