From 07e4d5826f83e61fcf195609bfb9ff77e28c0bf1 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Wed, 28 May 2025 14:24:02 +0200 Subject: [PATCH] fix: Recognize salsa cycles in `thread_result_to_response` --- crates/rust-analyzer/src/handlers/dispatch.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/rust-analyzer/src/handlers/dispatch.rs b/crates/rust-analyzer/src/handlers/dispatch.rs index f04ada3889..40d05567fc 100644 --- a/crates/rust-analyzer/src/handlers/dispatch.rs +++ b/crates/rust-analyzer/src/handlers/dispatch.rs @@ -6,7 +6,7 @@ use std::{ use ide_db::base_db::{ DbPanicContext, - salsa::{self, Cancelled}, + salsa::{self, Cancelled, UnexpectedCycle}, }; use lsp_server::{ExtractError, Response, ResponseError}; use serde::{Serialize, de::DeserializeOwned}; @@ -349,11 +349,14 @@ where let mut message = "request handler panicked".to_owned(); if let Some(panic_message) = panic_message { message.push_str(": "); - message.push_str(panic_message) + message.push_str(panic_message); + } else if let Some(cycle) = panic.downcast_ref::() { + tracing::error!("{cycle}"); + message.push_str(": unexpected cycle"); } else if let Ok(cancelled) = panic.downcast::() { tracing::error!("Cancellation propagated out of salsa! This is a bug"); return Err(HandlerCancelledError::Inner(*cancelled)); - } + }; Ok(lsp_server::Response::new_err( id,