]> git.lizzy.rs Git - rust.git/blobdiff - crates/rust-analyzer/src/cli/load_cargo.rs
clippy::redudant_borrow
[rust.git] / crates / rust-analyzer / src / cli / load_cargo.rs
index b1c0e015d62ebd2f524dee701418ab4654e511fe..b5f5519b43ef2b856fec20c3f5548cec07c04b64 100644 (file)
 
 use crate::reload::{ProjectFolders, SourceRootConfig};
 
-pub struct LoadCargoConfig {
-    pub load_out_dirs_from_check: bool,
-    pub wrap_rustc: bool,
-    pub with_proc_macro: bool,
+pub(crate) struct LoadCargoConfig {
+    pub(crate) load_out_dirs_from_check: bool,
+    pub(crate) wrap_rustc: bool,
+    pub(crate) with_proc_macro: bool,
+    pub(crate) prefill_caches: bool,
 }
 
-pub fn load_workspace_at(
+pub(crate) fn load_workspace_at(
     root: &Path,
     cargo_config: &CargoConfig,
     load_config: &LoadCargoConfig,
@@ -83,7 +84,9 @@ fn load_workspace(
     let host =
         load_crate_graph(crate_graph, project_folders.source_root_config, &mut vfs, &receiver);
 
-    host.analysis().prime_caches(|_| {})?;
+    if config.prefill_caches {
+        host.analysis().prime_caches(|_| {})?;
+    }
     Ok((host, vfs, proc_macro_client))
 }
 
@@ -123,7 +126,7 @@ fn load_crate_graph(
             }
         }
     }
-    let source_roots = source_root_config.partition(&vfs);
+    let source_roots = source_root_config.partition(vfs);
     analysis_change.set_roots(source_roots);
 
     analysis_change.set_crate_graph(crate_graph);
@@ -146,6 +149,7 @@ fn test_loading_rust_analyzer() -> Result<()> {
             load_out_dirs_from_check: false,
             wrap_rustc: false,
             with_proc_macro: false,
+            prefill_caches: false,
         };
         let (host, _vfs, _proc_macro) =
             load_workspace_at(path, &cargo_config, &load_cargo_config, &|_| {})?;