Skip to content

Commit 8990e37

Browse files
Implement check::RustAnalyzer
1 parent ba4b8b2 commit 8990e37

File tree

4 files changed

+58
-2
lines changed

4 files changed

+58
-2
lines changed

src/bootstrap/builder.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,7 @@ impl<'a> Builder<'a> {
621621
check::Clippy,
622622
check::Miri,
623623
check::Rls,
624+
check::RustAnalyzer,
624625
check::Rustfmt,
625626
check::Bootstrap
626627
),

src/bootstrap/check.rs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,61 @@ impl Step for CodegenBackend {
301301
}
302302
}
303303

304+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
305+
pub struct RustAnalyzer {
306+
pub target: TargetSelection,
307+
}
308+
309+
impl Step for RustAnalyzer {
310+
type Output = ();
311+
const ONLY_HOSTS: bool = true;
312+
const DEFAULT: bool = true;
313+
314+
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
315+
run.paths(&["src/tools/rust-analyzer", "rust-analyzer"])
316+
}
317+
318+
fn make_run(run: RunConfig<'_>) {
319+
run.builder.ensure(RustAnalyzer { target: run.target });
320+
}
321+
322+
fn run(self, builder: &Builder<'_>) {
323+
let compiler = builder.compiler(builder.top_stage, builder.config.build);
324+
let target = self.target;
325+
326+
builder.ensure(Rustc { target });
327+
328+
let mut cargo = prepare_tool_cargo(
329+
builder,
330+
compiler,
331+
Mode::ToolRustc,
332+
target,
333+
cargo_subcommand(builder.kind),
334+
"src/tools/rust-analyzer",
335+
SourceType::InTree,
336+
&["rust-analyzer/in-rust-tree".to_owned()],
337+
);
338+
339+
// For ./x.py clippy, don't run with --all-targets because
340+
// linting tests and benchmarks can produce very noisy results
341+
if builder.kind != Kind::Clippy {
342+
cargo.arg("--all-targets");
343+
}
344+
345+
builder.info(&format!(
346+
"Checking stage{} {} artifacts ({} -> {})",
347+
builder.top_stage, "rust-analyzer", &compiler.host.triple, target.triple
348+
));
349+
run_cargo(builder, cargo, args(builder), &stamp(builder, compiler, target), vec![], true);
350+
351+
/// Cargo's output path in a given stage, compiled by a particular
352+
/// compiler for the specified target.
353+
fn stamp(builder: &Builder<'_>, compiler: Compiler, target: TargetSelection) -> PathBuf {
354+
builder.cargo_out(compiler, Mode::ToolRustc, target).join(".rust-analyzer-check.stamp")
355+
}
356+
}
357+
}
358+
304359
macro_rules! tool_check_step {
305360
($name:ident, $path:literal, $($alias:literal, )* $source_type:path $(, $default:literal )?) => {
306361
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]

src/bootstrap/dist.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,7 @@ impl Step for RustAnalyzer {
10611061
.ensure(tool::RustAnalyzer {
10621062
compiler,
10631063
target,
1064-
extra_features: vec!["in-rust-tree".to_owned()]
1064+
extra_features: vec!["in-rust-tree".to_owned()],
10651065
})
10661066
.expect("rust-analyzer always builds");
10671067

src/bootstrap/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ impl Step for RustAnalyzer {
381381
.ensure(tool::RustAnalyzer {
382382
compiler,
383383
target: self.host,
384-
extra_features: vec!["in-rust-tree".to_owned()]
384+
extra_features: vec!["in-rust-tree".to_owned()],
385385
})
386386
.expect("in-tree tool");
387387

0 commit comments

Comments
 (0)