Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 0f2266d

Browse files
Convert rust-analyzer to 'in-tree' tool, pass 'in-rust-tree' feature by default
1 parent 43acb50 commit 0f2266d

File tree

3 files changed

+47
-4
lines changed

3 files changed

+47
-4
lines changed

src/bootstrap/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1551,7 +1551,7 @@ impl<'a> Builder<'a> {
15511551
Mode::ToolStd => {
15521552
// Right now this is just compiletest and a few other tools that build on stable.
15531553
// Allow them to use `feature(test)`, but nothing else.
1554-
rustflags.arg("-Zallow-features=binary-dep-depinfo,test,backtrace");
1554+
rustflags.arg("-Zallow-features=binary-dep-depinfo,test,backtrace,proc_macro_internals,proc_macro_diagnostic,proc_macro_span");
15551555
}
15561556
Mode::Std | Mode::Rustc | Mode::Codegen | Mode::ToolRustc => {}
15571557
}

src/bootstrap/dist.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ impl Step for RustAnalyzer {
10581058
}
10591059

10601060
let rust_analyzer = builder
1061-
.ensure(tool::RustAnalyzer { compiler, target, extra_features: Vec::new() })
1061+
.ensure(tool::RustAnalyzer { compiler, target })
10621062
.expect("rust-analyzer always builds");
10631063

10641064
let mut tarball = Tarball::new(builder, "rust-analyzer", &target.triple);

src/bootstrap/tool.rs

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::collections::HashSet;
22
use std::env;
33
use std::fs;
4-
use std::path::{Path, PathBuf};
4+
use std::path::PathBuf;
55
use std::process::Command;
66

77
use crate::builder::{Builder, Cargo as CargoCommand, RunConfig, ShouldRun, Step};
@@ -683,6 +683,50 @@ impl Step for LldWrapper {
683683
}
684684
}
685685

686+
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
687+
pub struct RustAnalyzer {
688+
pub compiler: Compiler,
689+
pub target: TargetSelection,
690+
}
691+
692+
impl Step for RustAnalyzer {
693+
type Output = Option<PathBuf>;
694+
const DEFAULT: bool = true;
695+
const ONLY_HOSTS: bool = true;
696+
697+
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
698+
let builder = run.builder;
699+
run.path("src/tools/rust-analyzer/crates/rust-analyzer").default_condition(
700+
builder.config.extended
701+
&& builder
702+
.config
703+
.tools
704+
.as_ref()
705+
.map_or(true, |tools| tools.iter().any(|tool| tool == "rust-analyzer")),
706+
)
707+
}
708+
709+
fn make_run(run: RunConfig<'_>) {
710+
run.builder.ensure(RustAnalyzer {
711+
compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build),
712+
target: run.target,
713+
});
714+
}
715+
716+
fn run(self, builder: &Builder<'_>) -> Option<PathBuf> {
717+
builder.ensure(ToolBuild {
718+
compiler: self.compiler,
719+
target: self.target,
720+
tool: "rust-analyzer",
721+
mode: Mode::ToolStd,
722+
path: "src/tools/rust-analyzer/crates/rust-analyzer",
723+
extra_features: vec!["in-rust-tree".to_owned()],
724+
is_optional_tool: true,
725+
source_type: SourceType::InTree,
726+
})
727+
}
728+
}
729+
686730
macro_rules! tool_extended {
687731
(($sel:ident, $builder:ident),
688732
$($name:ident,
@@ -780,7 +824,6 @@ tool_extended!((self, builder),
780824
// and this is close enough for now.
781825
RustDemangler, rust_demangler, "src/tools/rust-demangler", "rust-demangler", stable=false, in_tree=true, tool_std=true, {};
782826
Rustfmt, rustfmt, "src/tools/rustfmt", "rustfmt", stable=true, in_tree=true, {};
783-
RustAnalyzer, rust_analyzer, "src/tools/rust-analyzer/crates/rust-analyzer", "rust-analyzer", stable=true, submodule="rust-analyzer", {};
784827
);
785828

786829
impl<'a> Builder<'a> {

0 commit comments

Comments
 (0)