Skip to content

Commit d4c9963

Browse files
committed
Fixup rust-analyzer checking
1 parent a702d4c commit d4c9963

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

src/bootstrap/src/core/build_steps/check.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,10 @@ impl Step for CodegenBackend {
321321
}
322322
}
323323

324+
/// Checks Rust analyzer that links to .rmetas from a checked rustc.
324325
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
325326
pub struct RustAnalyzer {
327+
pub build_compiler: Compiler,
326328
pub target: TargetSelection,
327329
}
328330

@@ -343,18 +345,17 @@ impl Step for RustAnalyzer {
343345
}
344346

345347
fn make_run(run: RunConfig<'_>) {
346-
run.builder.ensure(RustAnalyzer { target: run.target });
348+
let build_compiler = prepare_compiler_for_tool_rustc(run.builder, run.target);
349+
run.builder.ensure(RustAnalyzer { build_compiler, target: run.target });
347350
}
348351

349352
fn run(self, builder: &Builder<'_>) {
350-
let compiler = builder.compiler(builder.top_stage, builder.config.host_target);
353+
let build_compiler = self.build_compiler;
351354
let target = self.target;
352355

353-
builder.ensure(Rustc::new(target, builder));
354-
355356
let mut cargo = prepare_tool_cargo(
356357
builder,
357-
compiler,
358+
build_compiler,
358359
Mode::ToolRustc,
359360
target,
360361
builder.kind,
@@ -371,12 +372,16 @@ impl Step for RustAnalyzer {
371372

372373
// Cargo's output path in a given stage, compiled by a particular
373374
// compiler for the specified target.
374-
let stamp = BuildStamp::new(&builder.cargo_out(compiler, Mode::ToolRustc, target))
375+
let stamp = BuildStamp::new(&builder.cargo_out(build_compiler, Mode::ToolRustc, target))
375376
.with_prefix("rust-analyzer-check");
376377

377378
let _guard = builder.msg_check("rust-analyzer artifacts", target, None);
378379
run_cargo(builder, cargo, builder.config.free_args.clone(), &stamp, vec![], true, false);
379380
}
381+
382+
fn metadata(&self) -> Option<StepMetadata> {
383+
Some(StepMetadata::check("rust-analyzer", self.target).built_by(self.build_compiler))
384+
}
380385
}
381386

382387
/// Compiletest is implicitly "checked" when it gets built in order to run tests,

src/bootstrap/src/core/builder/tests.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,6 +1435,19 @@ mod snapshot {
14351435
");
14361436
}
14371437

1438+
#[test]
1439+
fn check_rust_analyzer() {
1440+
let ctx = TestCtx::new();
1441+
insta::assert_snapshot!(
1442+
ctx.config("check")
1443+
.path("rust-analyzer")
1444+
.render_steps(), @r"
1445+
[build] llvm <host>
1446+
[check] rustc 0 <host> -> rustc 1 <host>
1447+
[check] rustc 0 <host> -> rust-analyzer 1 <host>
1448+
");
1449+
}
1450+
14381451
#[test]
14391452
fn test_exclude() {
14401453
let ctx = TestCtx::new();

0 commit comments

Comments
 (0)