Unnamed repository; edit this file 'description' to name the repository.
-rw-r--r--crates/rust-analyzer/src/main_loop.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs
index 64decc9e0d..eb272b5e0b 100644
--- a/crates/rust-analyzer/src/main_loop.rs
+++ b/crates/rust-analyzer/src/main_loop.rs
@@ -303,6 +303,15 @@ impl GlobalState {
.map(Some)
}
+ fn trigger_garbage_collection(&mut self) {
+ if cfg!(test) {
+ // Slow tests run the main loop in multiple threads, but GC isn't thread safe.
+ return;
+ }
+
+ self.analysis_host.trigger_garbage_collection();
+ }
+
fn handle_event(&mut self, event: Event) {
let loop_start = Instant::now();
let _p = tracing::info_span!("GlobalState::handle_event", event = %event).entered();
@@ -383,7 +392,7 @@ impl GlobalState {
));
}
PrimeCachesProgress::End { cancelled } => {
- self.analysis_host.trigger_garbage_collection();
+ self.trigger_garbage_collection();
self.prime_caches_queue.op_completed(());
if cancelled {
self.prime_caches_queue
@@ -542,7 +551,7 @@ impl GlobalState {
&& self.fmt_pool.handle.is_empty()
&& current_revision != self.last_gc_revision
{
- self.analysis_host.trigger_garbage_collection();
+ self.trigger_garbage_collection();
self.last_gc_revision = current_revision;
}
}