aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ide/src/prime_caches.rs7
-rw-r--r--crates/rust-analyzer/src/cli.rs1
-rw-r--r--crates/rust-analyzer/src/cli/analysis_stats.rs1
-rw-r--r--crates/rust-analyzer/src/cli/diagnostics.rs8
-rw-r--r--crates/rust-analyzer/src/cli/load_cargo.rs18
-rw-r--r--crates/rust-analyzer/src/cli/ssr.rs9
-rw-r--r--crates/rust-analyzer/src/integrated_benchmarks.rs2
7 files changed, 32 insertions, 14 deletions
diff --git a/crates/ide/src/prime_caches.rs b/crates/ide/src/prime_caches.rs
index d912a01b8..36801c964 100644
--- a/crates/ide/src/prime_caches.rs
+++ b/crates/ide/src/prime_caches.rs
@@ -33,14 +33,15 @@ pub(crate) fn prime_caches(db: &RootDatabase, cb: &(dyn Fn(PrimeCachesProgress)
33 // FIXME: This would be easy to parallelize, since it's in the ideal ordering for that. 33 // FIXME: This would be easy to parallelize, since it's in the ideal ordering for that.
34 // Unfortunately rayon prevents panics from propagation out of a `scope`, which breaks 34 // Unfortunately rayon prevents panics from propagation out of a `scope`, which breaks
35 // cancellation, so we cannot use rayon. 35 // cancellation, so we cannot use rayon.
36 for (i, krate) in topo.iter().enumerate() { 36 for (i, &crate_id) in topo.iter().enumerate() {
37 let crate_name = graph[*krate].display_name.as_deref().unwrap_or_default().to_string(); 37 let crate_name = graph[crate_id].display_name.as_deref().unwrap_or_default().to_string();
38 38
39 cb(PrimeCachesProgress::StartedOnCrate { 39 cb(PrimeCachesProgress::StartedOnCrate {
40 on_crate: crate_name, 40 on_crate: crate_name,
41 n_done: i, 41 n_done: i,
42 n_total: topo.len(), 42 n_total: topo.len(),
43 }); 43 });
44 db.crate_def_map(*krate); 44 db.crate_def_map(crate_id);
45 db.import_map(crate_id);
45 } 46 }
46} 47}
diff --git a/crates/rust-analyzer/src/cli.rs b/crates/rust-analyzer/src/cli.rs
index 76b666dc2..25ebcc0ec 100644
--- a/crates/rust-analyzer/src/cli.rs
+++ b/crates/rust-analyzer/src/cli.rs
@@ -16,7 +16,6 @@ use vfs::Vfs;
16pub use self::{ 16pub use self::{
17 analysis_stats::AnalysisStatsCmd, 17 analysis_stats::AnalysisStatsCmd,
18 diagnostics::diagnostics, 18 diagnostics::diagnostics,
19 load_cargo::{load_workspace, load_workspace_at, LoadCargoConfig},
20 ssr::{apply_ssr_rules, search_for_patterns}, 19 ssr::{apply_ssr_rules, search_for_patterns},
21}; 20};
22 21
diff --git a/crates/rust-analyzer/src/cli/analysis_stats.rs b/crates/rust-analyzer/src/cli/analysis_stats.rs
index 5364e907c..843c0ca37 100644
--- a/crates/rust-analyzer/src/cli/analysis_stats.rs
+++ b/crates/rust-analyzer/src/cli/analysis_stats.rs
@@ -70,6 +70,7 @@ impl AnalysisStatsCmd {
70 load_out_dirs_from_check: self.enable_build_scripts, 70 load_out_dirs_from_check: self.enable_build_scripts,
71 wrap_rustc: false, 71 wrap_rustc: false,
72 with_proc_macro: self.enable_proc_macros, 72 with_proc_macro: self.enable_proc_macros,
73 prefill_caches: false,
73 }; 74 };
74 let (host, vfs, _proc_macro) = 75 let (host, vfs, _proc_macro) =
75 load_workspace_at(&self.path, &cargo_config, &load_cargo_config, &|_| {})?; 76 load_workspace_at(&self.path, &cargo_config, &load_cargo_config, &|_| {})?;
diff --git a/crates/rust-analyzer/src/cli/diagnostics.rs b/crates/rust-analyzer/src/cli/diagnostics.rs
index c33c8179c..dc9a390fe 100644
--- a/crates/rust-analyzer/src/cli/diagnostics.rs
+++ b/crates/rust-analyzer/src/cli/diagnostics.rs
@@ -34,8 +34,12 @@ pub fn diagnostics(
34 with_proc_macro: bool, 34 with_proc_macro: bool,
35) -> Result<()> { 35) -> Result<()> {
36 let cargo_config = Default::default(); 36 let cargo_config = Default::default();
37 let load_cargo_config = 37 let load_cargo_config = LoadCargoConfig {
38 LoadCargoConfig { load_out_dirs_from_check, with_proc_macro, wrap_rustc: false }; 38 load_out_dirs_from_check,
39 with_proc_macro,
40 wrap_rustc: false,
41 prefill_caches: false,
42 };
39 let (host, _vfs, _proc_macro) = 43 let (host, _vfs, _proc_macro) =
40 load_workspace_at(path, &cargo_config, &load_cargo_config, &|_| {})?; 44 load_workspace_at(path, &cargo_config, &load_cargo_config, &|_| {})?;
41 let db = host.raw_database(); 45 let db = host.raw_database();
diff --git a/crates/rust-analyzer/src/cli/load_cargo.rs b/crates/rust-analyzer/src/cli/load_cargo.rs
index 8cee65478..19cb1c046 100644
--- a/crates/rust-analyzer/src/cli/load_cargo.rs
+++ b/crates/rust-analyzer/src/cli/load_cargo.rs
@@ -14,13 +14,14 @@ use vfs::{loader::Handle, AbsPath, AbsPathBuf};
14 14
15use crate::reload::{ProjectFolders, SourceRootConfig}; 15use crate::reload::{ProjectFolders, SourceRootConfig};
16 16
17pub struct LoadCargoConfig { 17pub(crate) struct LoadCargoConfig {
18 pub load_out_dirs_from_check: bool, 18 pub(crate) load_out_dirs_from_check: bool,
19 pub wrap_rustc: bool, 19 pub(crate) wrap_rustc: bool,
20 pub with_proc_macro: bool, 20 pub(crate) with_proc_macro: bool,
21 pub(crate) prefill_caches: bool,
21} 22}
22 23
23pub fn load_workspace_at( 24pub(crate) fn load_workspace_at(
24 root: &Path, 25 root: &Path,
25 cargo_config: &CargoConfig, 26 cargo_config: &CargoConfig,
26 load_config: &LoadCargoConfig, 27 load_config: &LoadCargoConfig,
@@ -33,7 +34,7 @@ pub fn load_workspace_at(
33 load_workspace(workspace, load_config, progress) 34 load_workspace(workspace, load_config, progress)
34} 35}
35 36
36pub fn load_workspace( 37fn load_workspace(
37 ws: ProjectWorkspace, 38 ws: ProjectWorkspace,
38 config: &LoadCargoConfig, 39 config: &LoadCargoConfig,
39 progress: &dyn Fn(String), 40 progress: &dyn Fn(String),
@@ -82,6 +83,10 @@ pub fn load_workspace(
82 log::debug!("crate graph: {:?}", crate_graph); 83 log::debug!("crate graph: {:?}", crate_graph);
83 let host = 84 let host =
84 load_crate_graph(crate_graph, project_folders.source_root_config, &mut vfs, &receiver); 85 load_crate_graph(crate_graph, project_folders.source_root_config, &mut vfs, &receiver);
86
87 if config.prefill_caches {
88 host.analysis().prime_caches(|_| {})?;
89 }
85 Ok((host, vfs, proc_macro_client)) 90 Ok((host, vfs, proc_macro_client))
86} 91}
87 92
@@ -144,6 +149,7 @@ mod tests {
144 load_out_dirs_from_check: false, 149 load_out_dirs_from_check: false,
145 wrap_rustc: false, 150 wrap_rustc: false,
146 with_proc_macro: false, 151 with_proc_macro: false,
152 prefill_caches: false,
147 }; 153 };
148 let (host, _vfs, _proc_macro) = 154 let (host, _vfs, _proc_macro) =
149 load_workspace_at(path, &cargo_config, &load_cargo_config, &|_| {})?; 155 load_workspace_at(path, &cargo_config, &load_cargo_config, &|_| {})?;
diff --git a/crates/rust-analyzer/src/cli/ssr.rs b/crates/rust-analyzer/src/cli/ssr.rs
index 1fd9b5a9b..0b3475e09 100644
--- a/crates/rust-analyzer/src/cli/ssr.rs
+++ b/crates/rust-analyzer/src/cli/ssr.rs
@@ -13,6 +13,7 @@ pub fn apply_ssr_rules(rules: Vec<SsrRule>) -> Result<()> {
13 load_out_dirs_from_check: true, 13 load_out_dirs_from_check: true,
14 wrap_rustc: false, 14 wrap_rustc: false,
15 with_proc_macro: true, 15 with_proc_macro: true,
16 prefill_caches: false,
16 }; 17 };
17 let (host, vfs, _proc_macro) = 18 let (host, vfs, _proc_macro) =
18 load_workspace_at(&std::env::current_dir()?, &cargo_config, &load_cargo_config, &|_| {})?; 19 load_workspace_at(&std::env::current_dir()?, &cargo_config, &load_cargo_config, &|_| {})?;
@@ -39,8 +40,12 @@ pub fn search_for_patterns(patterns: Vec<SsrPattern>, debug_snippet: Option<Stri
39 use ide_db::base_db::SourceDatabaseExt; 40 use ide_db::base_db::SourceDatabaseExt;
40 use ide_db::symbol_index::SymbolsDatabase; 41 use ide_db::symbol_index::SymbolsDatabase;
41 let cargo_config = Default::default(); 42 let cargo_config = Default::default();
42 let load_cargo_config = 43 let load_cargo_config = LoadCargoConfig {
43 LoadCargoConfig { load_out_dirs_from_check: true, wrap_rustc: true, with_proc_macro: true }; 44 load_out_dirs_from_check: true,
45 wrap_rustc: true,
46 with_proc_macro: true,
47 prefill_caches: false,
48 };
44 let (host, _vfs, _proc_macro) = 49 let (host, _vfs, _proc_macro) =
45 load_workspace_at(&std::env::current_dir()?, &cargo_config, &load_cargo_config, &|_| {})?; 50 load_workspace_at(&std::env::current_dir()?, &cargo_config, &load_cargo_config, &|_| {})?;
46 let db = host.raw_database(); 51 let db = host.raw_database();
diff --git a/crates/rust-analyzer/src/integrated_benchmarks.rs b/crates/rust-analyzer/src/integrated_benchmarks.rs
index ec36a5f5c..8ddeb59f7 100644
--- a/crates/rust-analyzer/src/integrated_benchmarks.rs
+++ b/crates/rust-analyzer/src/integrated_benchmarks.rs
@@ -37,6 +37,7 @@ fn integrated_highlighting_benchmark() {
37 load_out_dirs_from_check: true, 37 load_out_dirs_from_check: true,
38 wrap_rustc: false, 38 wrap_rustc: false,
39 with_proc_macro: false, 39 with_proc_macro: false,
40 prefill_caches: false,
40 }; 41 };
41 42
42 let (mut host, vfs, _proc_macro) = { 43 let (mut host, vfs, _proc_macro) = {
@@ -91,6 +92,7 @@ fn integrated_completion_benchmark() {
91 load_out_dirs_from_check: true, 92 load_out_dirs_from_check: true,
92 wrap_rustc: false, 93 wrap_rustc: false,
93 with_proc_macro: false, 94 with_proc_macro: false,
95 prefill_caches: true,
94 }; 96 };
95 97
96 let (mut host, vfs, _proc_macro) = { 98 let (mut host, vfs, _proc_macro) = {