diff options
author | Aleksey Kladov <[email protected]> | 2021-01-18 11:52:12 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2021-01-18 11:52:12 +0000 |
commit | add87f54240a20e72136a403c166113af5173572 (patch) | |
tree | 14ed8b5ca07a40dea9b0599506d78b3d6f4c4a6c /crates/rust-analyzer/src/reload.rs | |
parent | cc963d2b1190578ad9f1d1f4589e8ea2c98c1a14 (diff) |
Avoid blocking the main loop when editing Cargo.toml
I've noticed a bunch of "main loop too long" warnings in console when
typing in Cargo.toml. Profiling showed that the culprit is `rustc
--print cfg` call.
I moved it to the background project loading phase, where it belongs.
This highlighted a problem: we generally use single `cfg`, while it
really should be per crate.
Diffstat (limited to 'crates/rust-analyzer/src/reload.rs')
-rw-r--r-- | crates/rust-analyzer/src/reload.rs | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs index 34e3cfe68..dabfb4241 100644 --- a/crates/rust-analyzer/src/reload.rs +++ b/crates/rust-analyzer/src/reload.rs | |||
@@ -135,7 +135,10 @@ impl GlobalState { | |||
135 | ) | 135 | ) |
136 | } | 136 | } |
137 | LinkedProject::InlineJsonProject(it) => { | 137 | LinkedProject::InlineJsonProject(it) => { |
138 | project_model::ProjectWorkspace::load_inline(it.clone()) | 138 | project_model::ProjectWorkspace::load_inline( |
139 | it.clone(), | ||
140 | cargo_config.target.as_deref(), | ||
141 | ) | ||
139 | } | 142 | } |
140 | }) | 143 | }) |
141 | .collect::<Vec<_>>(); | 144 | .collect::<Vec<_>>(); |
@@ -253,11 +256,7 @@ impl GlobalState { | |||
253 | res | 256 | res |
254 | }; | 257 | }; |
255 | for ws in workspaces.iter() { | 258 | for ws in workspaces.iter() { |
256 | crate_graph.extend(ws.to_crate_graph( | 259 | crate_graph.extend(ws.to_crate_graph(self.proc_macro_client.as_ref(), &mut load)); |
257 | self.config.cargo().target.as_deref(), | ||
258 | self.proc_macro_client.as_ref(), | ||
259 | &mut load, | ||
260 | )); | ||
261 | } | 260 | } |
262 | 261 | ||
263 | crate_graph | 262 | crate_graph |
@@ -289,9 +288,7 @@ impl GlobalState { | |||
289 | .iter() | 288 | .iter() |
290 | .enumerate() | 289 | .enumerate() |
291 | .filter_map(|(id, w)| match w { | 290 | .filter_map(|(id, w)| match w { |
292 | ProjectWorkspace::Cargo { cargo, sysroot: _, rustc: _ } => { | 291 | ProjectWorkspace::Cargo { cargo, .. } => Some((id, cargo.workspace_root())), |
293 | Some((id, cargo.workspace_root())) | ||
294 | } | ||
295 | ProjectWorkspace::Json { project, .. } => { | 292 | ProjectWorkspace::Json { project, .. } => { |
296 | // Enable flychecks for json projects if a custom flycheck command was supplied | 293 | // Enable flychecks for json projects if a custom flycheck command was supplied |
297 | // in the workspace configuration. | 294 | // in the workspace configuration. |