diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 575cbc3beb2..dee6228fe1a 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -1551,7 +1551,7 @@ impl<'a> Builder<'a> { Mode::ToolStd => { // Right now this is just compiletest and a few other tools that build on stable. // Allow them to use `feature(test)`, but nothing else. - rustflags.arg("-Zallow-features=binary-dep-depinfo,test,backtrace"); + rustflags.arg("-Zallow-features=binary-dep-depinfo,test,backtrace,proc_macro_internals,proc_macro_diagnostic,proc_macro_span"); } Mode::Std | Mode::Rustc | Mode::Codegen | Mode::ToolRustc => {} } diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index cba013b5bb6..95655c0ee35 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -1058,7 +1058,7 @@ impl Step for RustAnalyzer { } let rust_analyzer = builder - .ensure(tool::RustAnalyzer { compiler, target, extra_features: Vec::new() }) + .ensure(tool::RustAnalyzer { compiler, target }) .expect("rust-analyzer always builds"); let mut tarball = Tarball::new(builder, "rust-analyzer", &target.triple); diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index f659ccbe250..5743548d969 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -1,7 +1,7 @@ use std::collections::HashSet; use std::env; use std::fs; -use std::path::{Path, PathBuf}; +use std::path::PathBuf; use std::process::Command; use crate::builder::{Builder, Cargo as CargoCommand, RunConfig, ShouldRun, Step}; @@ -683,6 +683,50 @@ impl Step for LldWrapper { } } +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct RustAnalyzer { + pub compiler: Compiler, + pub target: TargetSelection, +} + +impl Step for RustAnalyzer { + type Output = Option; + const DEFAULT: bool = true; + const ONLY_HOSTS: bool = true; + + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { + let builder = run.builder; + run.path("src/tools/rust-analyzer/crates/rust-analyzer").default_condition( + builder.config.extended + && builder + .config + .tools + .as_ref() + .map_or(true, |tools| tools.iter().any(|tool| tool == "rust-analyzer")), + ) + } + + fn make_run(run: RunConfig<'_>) { + run.builder.ensure(RustAnalyzer { + compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build), + target: run.target, + }); + } + + fn run(self, builder: &Builder<'_>) -> Option { + builder.ensure(ToolBuild { + compiler: self.compiler, + target: self.target, + tool: "rust-analyzer", + mode: Mode::ToolStd, + path: "src/tools/rust-analyzer/crates/rust-analyzer", + extra_features: vec!["in-rust-tree".to_owned()], + is_optional_tool: true, + source_type: SourceType::InTree, + }) + } +} + macro_rules! tool_extended { (($sel:ident, $builder:ident), $($name:ident, @@ -780,7 +824,6 @@ tool_extended!((self, builder), // and this is close enough for now. RustDemangler, rust_demangler, "src/tools/rust-demangler", "rust-demangler", stable=false, in_tree=true, tool_std=true, {}; Rustfmt, rustfmt, "src/tools/rustfmt", "rustfmt", stable=true, in_tree=true, {}; - RustAnalyzer, rust_analyzer, "src/tools/rust-analyzer/crates/rust-analyzer", "rust-analyzer", stable=true, submodule="rust-analyzer", {}; ); impl<'a> Builder<'a> {