Skip to content

Commit 4416507

Browse files
committed
Auto merge of rust-lang#135575 - Veykril:push-ynurtulswkpo, r=Mark-Simulacrum
Backport rust-lang/rust-analyzer#18760
2 parents 752fecf + 5904ea4 commit 4416507

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

src/tools/rust-analyzer/crates/proc-macro-srv/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ fn expand_id(
175175
});
176176
let res = match thread {
177177
Ok(handle) => handle.join(),
178-
Err(e) => std::panic::resume_unwind(Box::new(e)),
178+
Err(e) => return Err(e.to_string()),
179179
};
180180

181181
match res {
@@ -223,7 +223,7 @@ fn expand_ra_span(
223223
});
224224
let res = match thread {
225225
Ok(handle) => handle.join(),
226-
Err(e) => std::panic::resume_unwind(Box::new(e)),
226+
Err(e) => return Err(e.to_string()),
227227
};
228228

229229
match res {

src/tools/rust-analyzer/crates/ra-salsa/src/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -610,11 +610,9 @@ where
610610
#[non_exhaustive]
611611
pub enum Cancelled {
612612
/// The query was operating on revision R, but there is a pending write to move to revision R+1.
613-
#[non_exhaustive]
614613
PendingWrite,
615614

616615
/// The query was blocked on another thread, and that thread panicked.
617-
#[non_exhaustive]
618616
PropagatedPanic,
619617
}
620618

src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/dispatch.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use std::{
55
};
66

77
use ide::Cancelled;
8+
use ide_db::base_db::ra_salsa::Cycle;
89
use lsp_server::{ExtractError, Response, ResponseError};
910
use serde::{de::DeserializeOwned, Serialize};
1011
use stdx::thread::ThreadIntent;
@@ -328,7 +329,13 @@ where
328329
if let Some(panic_message) = panic_message {
329330
message.push_str(": ");
330331
message.push_str(panic_message)
331-
};
332+
} else if let Some(cycle) = panic.downcast_ref::<Cycle>() {
333+
tracing::error!("Cycle propagated out of salsa! This is a bug: {cycle:?}");
334+
return Err(Cancelled::PropagatedPanic);
335+
} else if let Ok(cancelled) = panic.downcast::<Cancelled>() {
336+
tracing::error!("Cancellation propagated out of salsa! This is a bug");
337+
return Err(*cancelled);
338+
}
332339

333340
Ok(lsp_server::Response::new_err(
334341
id,

0 commit comments

Comments
 (0)