diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 74768c8e59e..8876f70c8c6 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -649,6 +649,7 @@ impl<'a> Builder<'a> { test::Cargotest, test::Cargo, test::Rls, + test::RustAnalyzer, test::ErrorIndex, test::Distcheck, test::RunMakeFullDeps, diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 078207d85fe..9578520c429 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -352,6 +352,55 @@ impl Step for Rls { } } +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub struct RustAnalyzer { + stage: u32, + host: TargetSelection, +} + +impl Step for RustAnalyzer { + type Output = (); + const ONLY_HOSTS: bool = true; + const DEFAULT: bool = true; + + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { + run.path("src/tools/rust-analyzer") + } + + fn make_run(run: RunConfig<'_>) { + run.builder.ensure(Self { stage: run.builder.top_stage, host: run.target }); + } + + /// Runs `cargo test` for rust-analyzer + fn run(self, builder: &Builder<'_>) { + let stage = self.stage; + let host = self.host; + let compiler = builder.compiler(stage, host); + + builder.ensure(tool::RustAnalyzer { compiler, target: self.host }).expect("in-tree tool"); + + let path = "src/tools/rust-analyzer"; + let mut cargo = tool::prepare_tool_cargo( + builder, + compiler, + Mode::ToolStd, + host, + "test", + path, + SourceType::InTree, + &["rust-analyzer/in-rust-tree".to_owned()], + ); + + let dir = builder.src.join(path); + cargo.env("CARGO_WORKSPACE_DIR", &dir); + + cargo.add_rustc_lib_path(builder, compiler); + cargo.arg("--").args(builder.config.cmd.test_args()); + + builder.run(&mut cargo.into()); + } +} + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct Rustfmt { stage: u32,