From 2ced362e57231f3e2ef3d941a6b8520fd79ba46c Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Sun, 9 Jun 2024 13:03:01 +0200 Subject: [PATCH] Fix divide by zero --- crates/rust-analyzer/src/main_loop.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index e2909be41a..07414a6e49 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs @@ -3,6 +3,7 @@ use std::{ fmt, + ops::Div as _, time::{Duration, Instant}, }; @@ -499,7 +500,7 @@ impl GlobalState { tracing::trace!("updating notifications for {:?}", subscriptions); // Split up the work on multiple threads, but we don't wanna fill the entire task pool with // diagnostic tasks, so we limit the number of tasks to a quarter of the total thread pool. - let max_tasks = self.config.main_loop_num_threads() / 4; + let max_tasks = self.config.main_loop_num_threads().div(4).max(1); let chunk_length = subscriptions.len() / max_tasks; let remainder = subscriptions.len() % max_tasks;