mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
Revert "Support disabling rustc build scripts"
This reverts commit ddce6bb282
.
This commit is contained in:
parent
ddce6bb282
commit
bbecea03fd
10 changed files with 12 additions and 60 deletions
|
@ -274,19 +274,12 @@ impl ProjectWorkspace {
|
||||||
crate_graph
|
crate_graph
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn collect_build_data_configs(
|
pub fn collect_build_data_configs(&self, collector: &mut BuildDataCollector) {
|
||||||
&self,
|
|
||||||
collector: &mut BuildDataCollector,
|
|
||||||
for_private: bool,
|
|
||||||
) {
|
|
||||||
match self {
|
match self {
|
||||||
ProjectWorkspace::Cargo { cargo, rustc, .. } => {
|
ProjectWorkspace::Cargo { cargo, rustc, .. } => {
|
||||||
collector.add_config(&cargo.workspace_root(), cargo.build_data_config().clone());
|
collector.add_config(&cargo.workspace_root(), cargo.build_data_config().clone());
|
||||||
if for_private {
|
if let Some(rustc) = rustc {
|
||||||
if let Some(rustc) = rustc {
|
collector.add_config(rustc.workspace_root(), rustc.build_data_config().clone());
|
||||||
collector
|
|
||||||
.add_config(rustc.workspace_root(), rustc.build_data_config().clone());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
|
|
@ -68,9 +68,6 @@ impl BenchCmd {
|
||||||
let load_cargo_config = LoadCargoConfig {
|
let load_cargo_config = LoadCargoConfig {
|
||||||
load_out_dirs_from_check: self.load_output_dirs,
|
load_out_dirs_from_check: self.load_output_dirs,
|
||||||
with_proc_macro: self.with_proc_macro,
|
with_proc_macro: self.with_proc_macro,
|
||||||
// This will currently never have rustcSource set, however if in
|
|
||||||
// future it does this will handle that case
|
|
||||||
run_rustc_build_scripts: true,
|
|
||||||
};
|
};
|
||||||
let (mut host, vfs, _proc_macro) =
|
let (mut host, vfs, _proc_macro) =
|
||||||
load_workspace_at(&self.path, &cargo_config, &load_cargo_config, &|_| {})?;
|
load_workspace_at(&self.path, &cargo_config, &load_cargo_config, &|_| {})?;
|
||||||
|
|
|
@ -63,9 +63,6 @@ impl AnalysisStatsCmd {
|
||||||
let load_cargo_config = LoadCargoConfig {
|
let load_cargo_config = LoadCargoConfig {
|
||||||
load_out_dirs_from_check: self.load_output_dirs,
|
load_out_dirs_from_check: self.load_output_dirs,
|
||||||
with_proc_macro: self.with_proc_macro,
|
with_proc_macro: self.with_proc_macro,
|
||||||
// This will currently never have rustcSource set, however if in
|
|
||||||
// future it does this will handle that case
|
|
||||||
run_rustc_build_scripts: true,
|
|
||||||
};
|
};
|
||||||
let (host, vfs, _proc_macro) =
|
let (host, vfs, _proc_macro) =
|
||||||
load_workspace_at(&self.path, &cargo_config, &load_cargo_config, &|_| {})?;
|
load_workspace_at(&self.path, &cargo_config, &load_cargo_config, &|_| {})?;
|
||||||
|
|
|
@ -34,13 +34,7 @@ pub fn diagnostics(
|
||||||
with_proc_macro: bool,
|
with_proc_macro: bool,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let cargo_config = Default::default();
|
let cargo_config = Default::default();
|
||||||
let load_cargo_config = LoadCargoConfig {
|
let load_cargo_config = LoadCargoConfig { load_out_dirs_from_check, with_proc_macro };
|
||||||
load_out_dirs_from_check,
|
|
||||||
with_proc_macro,
|
|
||||||
// This will currently never have rustcSource set, however if in
|
|
||||||
// future it does this will handle that case
|
|
||||||
run_rustc_build_scripts: true,
|
|
||||||
};
|
|
||||||
let (host, _vfs, _proc_macro) =
|
let (host, _vfs, _proc_macro) =
|
||||||
load_workspace_at(path, &cargo_config, &load_cargo_config, &|_| {})?;
|
load_workspace_at(path, &cargo_config, &load_cargo_config, &|_| {})?;
|
||||||
let db = host.raw_database();
|
let db = host.raw_database();
|
||||||
|
|
|
@ -14,7 +14,6 @@ use vfs::{loader::Handle, AbsPath, AbsPathBuf};
|
||||||
use crate::reload::{ProjectFolders, SourceRootConfig};
|
use crate::reload::{ProjectFolders, SourceRootConfig};
|
||||||
|
|
||||||
pub struct LoadCargoConfig {
|
pub struct LoadCargoConfig {
|
||||||
pub run_rustc_build_scripts: bool,
|
|
||||||
pub load_out_dirs_from_check: bool,
|
pub load_out_dirs_from_check: bool,
|
||||||
pub with_proc_macro: bool,
|
pub with_proc_macro: bool,
|
||||||
}
|
}
|
||||||
|
@ -54,7 +53,7 @@ pub fn load_workspace(
|
||||||
|
|
||||||
let build_data = if config.load_out_dirs_from_check {
|
let build_data = if config.load_out_dirs_from_check {
|
||||||
let mut collector = BuildDataCollector::default();
|
let mut collector = BuildDataCollector::default();
|
||||||
ws.collect_build_data_configs(&mut collector, config.run_rustc_build_scripts);
|
ws.collect_build_data_configs(&mut collector);
|
||||||
Some(collector.collect(progress)?)
|
Some(collector.collect(progress)?)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
@ -137,11 +136,8 @@ mod tests {
|
||||||
fn test_loading_rust_analyzer() -> Result<()> {
|
fn test_loading_rust_analyzer() -> Result<()> {
|
||||||
let path = Path::new(env!("CARGO_MANIFEST_DIR")).parent().unwrap().parent().unwrap();
|
let path = Path::new(env!("CARGO_MANIFEST_DIR")).parent().unwrap().parent().unwrap();
|
||||||
let cargo_config = Default::default();
|
let cargo_config = Default::default();
|
||||||
let load_cargo_config = LoadCargoConfig {
|
let load_cargo_config =
|
||||||
load_out_dirs_from_check: false,
|
LoadCargoConfig { load_out_dirs_from_check: false, with_proc_macro: false };
|
||||||
with_proc_macro: false,
|
|
||||||
run_rustc_build_scripts: false,
|
|
||||||
};
|
|
||||||
let (host, _vfs, _proc_macro) =
|
let (host, _vfs, _proc_macro) =
|
||||||
load_workspace_at(path, &cargo_config, &load_cargo_config, &|_| {})?;
|
load_workspace_at(path, &cargo_config, &load_cargo_config, &|_| {})?;
|
||||||
|
|
||||||
|
|
|
@ -9,13 +9,8 @@ use ide_ssr::{MatchFinder, SsrPattern, SsrRule};
|
||||||
pub fn apply_ssr_rules(rules: Vec<SsrRule>) -> Result<()> {
|
pub fn apply_ssr_rules(rules: Vec<SsrRule>) -> Result<()> {
|
||||||
use ide_db::base_db::SourceDatabaseExt;
|
use ide_db::base_db::SourceDatabaseExt;
|
||||||
let cargo_config = Default::default();
|
let cargo_config = Default::default();
|
||||||
let load_cargo_config = LoadCargoConfig {
|
let load_cargo_config =
|
||||||
load_out_dirs_from_check: true,
|
LoadCargoConfig { load_out_dirs_from_check: true, with_proc_macro: true };
|
||||||
with_proc_macro: true,
|
|
||||||
// This will currently never have rustcSource set, however if in
|
|
||||||
// future it does this will handle that case
|
|
||||||
run_rustc_build_scripts: true,
|
|
||||||
};
|
|
||||||
let (host, vfs, _proc_macro) =
|
let (host, vfs, _proc_macro) =
|
||||||
load_workspace_at(&std::env::current_dir()?, &cargo_config, &load_cargo_config, &|_| {})?;
|
load_workspace_at(&std::env::current_dir()?, &cargo_config, &load_cargo_config, &|_| {})?;
|
||||||
let db = host.raw_database();
|
let db = host.raw_database();
|
||||||
|
@ -41,13 +36,8 @@ pub fn search_for_patterns(patterns: Vec<SsrPattern>, debug_snippet: Option<Stri
|
||||||
use ide_db::base_db::SourceDatabaseExt;
|
use ide_db::base_db::SourceDatabaseExt;
|
||||||
use ide_db::symbol_index::SymbolsDatabase;
|
use ide_db::symbol_index::SymbolsDatabase;
|
||||||
let cargo_config = Default::default();
|
let cargo_config = Default::default();
|
||||||
let load_cargo_config = LoadCargoConfig {
|
let load_cargo_config =
|
||||||
load_out_dirs_from_check: true,
|
LoadCargoConfig { load_out_dirs_from_check: true, with_proc_macro: true };
|
||||||
with_proc_macro: true,
|
|
||||||
// This will currently never have rustcSource set, however if in
|
|
||||||
// future it does this will handle that case
|
|
||||||
run_rustc_build_scripts: true,
|
|
||||||
};
|
|
||||||
let (host, _vfs, _proc_macro) =
|
let (host, _vfs, _proc_macro) =
|
||||||
load_workspace_at(&std::env::current_dir()?, &cargo_config, &load_cargo_config, &|_| {})?;
|
load_workspace_at(&std::env::current_dir()?, &cargo_config, &load_cargo_config, &|_| {})?;
|
||||||
let db = host.raw_database();
|
let db = host.raw_database();
|
||||||
|
|
|
@ -49,8 +49,6 @@ config_data! {
|
||||||
/// Run build scripts (`build.rs`) for more precise code analysis.
|
/// Run build scripts (`build.rs`) for more precise code analysis.
|
||||||
cargo_runBuildScripts |
|
cargo_runBuildScripts |
|
||||||
cargo_loadOutDirsFromCheck: bool = "false",
|
cargo_loadOutDirsFromCheck: bool = "false",
|
||||||
/// Disable running build scripts (`build.rs`) for the `rustc_private` crates in `rustcSource`.
|
|
||||||
cargo_disableRustcBuildScripts: bool = "false",
|
|
||||||
/// Do not activate the `default` feature.
|
/// Do not activate the `default` feature.
|
||||||
cargo_noDefaultFeatures: bool = "false",
|
cargo_noDefaultFeatures: bool = "false",
|
||||||
/// Compilation target (target triple).
|
/// Compilation target (target triple).
|
||||||
|
@ -484,9 +482,6 @@ impl Config {
|
||||||
pub fn run_build_scripts(&self) -> bool {
|
pub fn run_build_scripts(&self) -> bool {
|
||||||
self.data.cargo_runBuildScripts || self.data.procMacro_enable
|
self.data.cargo_runBuildScripts || self.data.procMacro_enable
|
||||||
}
|
}
|
||||||
pub fn run_rustc_build_scripts(&self) -> bool {
|
|
||||||
self.run_build_scripts() && !self.data.cargo_disableRustcBuildScripts
|
|
||||||
}
|
|
||||||
pub fn cargo(&self) -> CargoConfig {
|
pub fn cargo(&self) -> CargoConfig {
|
||||||
let rustc_source = self.data.rustcSource.as_ref().map(|rustc_src| {
|
let rustc_source = self.data.rustcSource.as_ref().map(|rustc_src| {
|
||||||
if rustc_src == "discover" {
|
if rustc_src == "discover" {
|
||||||
|
|
|
@ -340,10 +340,7 @@ impl GlobalState {
|
||||||
if self.config.run_build_scripts() && workspace_build_data.is_none() {
|
if self.config.run_build_scripts() && workspace_build_data.is_none() {
|
||||||
let mut collector = BuildDataCollector::default();
|
let mut collector = BuildDataCollector::default();
|
||||||
for ws in &workspaces {
|
for ws in &workspaces {
|
||||||
ws.collect_build_data_configs(
|
ws.collect_build_data_configs(&mut collector);
|
||||||
&mut collector,
|
|
||||||
self.config.run_rustc_build_scripts(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
self.fetch_build_data_request(collector)
|
self.fetch_build_data_request(collector)
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,6 @@
|
||||||
List of features to activate.
|
List of features to activate.
|
||||||
[[rust-analyzer.cargo.runBuildScripts]]rust-analyzer.cargo.runBuildScripts (default: `false`)::
|
[[rust-analyzer.cargo.runBuildScripts]]rust-analyzer.cargo.runBuildScripts (default: `false`)::
|
||||||
Run build scripts (`build.rs`) for more precise code analysis.
|
Run build scripts (`build.rs`) for more precise code analysis.
|
||||||
[[rust-analyzer.cargo.disableRustcBuildScripts]]rust-analyzer.cargo.disableRustcBuildScripts (default: `false`)::
|
|
||||||
Disable running build scripts (`build.rs`) for the `rustc_private` crates in `rustcSource`.
|
|
||||||
[[rust-analyzer.cargo.noDefaultFeatures]]rust-analyzer.cargo.noDefaultFeatures (default: `false`)::
|
[[rust-analyzer.cargo.noDefaultFeatures]]rust-analyzer.cargo.noDefaultFeatures (default: `false`)::
|
||||||
Do not activate the `default` feature.
|
Do not activate the `default` feature.
|
||||||
[[rust-analyzer.cargo.target]]rust-analyzer.cargo.target (default: `null`)::
|
[[rust-analyzer.cargo.target]]rust-analyzer.cargo.target (default: `null`)::
|
||||||
|
|
|
@ -413,11 +413,6 @@
|
||||||
"default": false,
|
"default": false,
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
"rust-analyzer.cargo.disableRustcBuildScripts": {
|
|
||||||
"markdownDescription": "Disable running build scripts (`build.rs`) for the `rustc_private` crates in `rustcSource`.",
|
|
||||||
"default": false,
|
|
||||||
"type": "boolean"
|
|
||||||
},
|
|
||||||
"rust-analyzer.cargo.noDefaultFeatures": {
|
"rust-analyzer.cargo.noDefaultFeatures": {
|
||||||
"markdownDescription": "Do not activate the `default` feature.",
|
"markdownDescription": "Do not activate the `default` feature.",
|
||||||
"default": false,
|
"default": false,
|
||||||
|
|
Loading…
Reference in a new issue