Skip to content

Commit

Permalink
Auto merge of rust-lang#135575 - Veykril:push-ynurtulswkpo, r=Mark-Si…
Browse files Browse the repository at this point in the history
…mulacrum

Backport rust-lang/rust-analyzer#18760
  • Loading branch information
bors committed Jan 20, 2025
2 parents 752fecf + 5904ea4 commit 4416507
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/tools/rust-analyzer/crates/proc-macro-srv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ fn expand_id(
});
let res = match thread {
Ok(handle) => handle.join(),
Err(e) => std::panic::resume_unwind(Box::new(e)),
Err(e) => return Err(e.to_string()),
};

match res {
Expand Down Expand Up @@ -223,7 +223,7 @@ fn expand_ra_span(
});
let res = match thread {
Ok(handle) => handle.join(),
Err(e) => std::panic::resume_unwind(Box::new(e)),
Err(e) => return Err(e.to_string()),
};

match res {
Expand Down
2 changes: 0 additions & 2 deletions src/tools/rust-analyzer/crates/ra-salsa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -610,11 +610,9 @@ where
#[non_exhaustive]
pub enum Cancelled {
/// The query was operating on revision R, but there is a pending write to move to revision R+1.
#[non_exhaustive]
PendingWrite,

/// The query was blocked on another thread, and that thread panicked.
#[non_exhaustive]
PropagatedPanic,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::{
};

use ide::Cancelled;
use ide_db::base_db::ra_salsa::Cycle;
use lsp_server::{ExtractError, Response, ResponseError};
use serde::{de::DeserializeOwned, Serialize};
use stdx::thread::ThreadIntent;
Expand Down Expand Up @@ -328,7 +329,13 @@ where
if let Some(panic_message) = panic_message {
message.push_str(": ");
message.push_str(panic_message)
};
} else if let Some(cycle) = panic.downcast_ref::<Cycle>() {
tracing::error!("Cycle propagated out of salsa! This is a bug: {cycle:?}");
return Err(Cancelled::PropagatedPanic);
} else if let Ok(cancelled) = panic.downcast::<Cancelled>() {
tracing::error!("Cancellation propagated out of salsa! This is a bug");
return Err(*cancelled);
}

Ok(lsp_server::Response::new_err(
id,
Expand Down

0 comments on commit 4416507

Please sign in to comment.