mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-01 07:48:45 +00:00
internal: Workaround salsa cycles leaking
This commit is contained in:
parent
bfc223e857
commit
ed8227c649
4 changed files with 11 additions and 6 deletions
|
@ -175,7 +175,7 @@ fn expand_id(
|
||||||
});
|
});
|
||||||
let res = match thread {
|
let res = match thread {
|
||||||
Ok(handle) => handle.join(),
|
Ok(handle) => handle.join(),
|
||||||
Err(e) => std::panic::resume_unwind(Box::new(e)),
|
Err(e) => return Err(e.to_string()),
|
||||||
};
|
};
|
||||||
|
|
||||||
match res {
|
match res {
|
||||||
|
@ -223,7 +223,7 @@ fn expand_ra_span(
|
||||||
});
|
});
|
||||||
let res = match thread {
|
let res = match thread {
|
||||||
Ok(handle) => handle.join(),
|
Ok(handle) => handle.join(),
|
||||||
Err(e) => std::panic::resume_unwind(Box::new(e)),
|
Err(e) => return Err(e.to_string()),
|
||||||
};
|
};
|
||||||
|
|
||||||
match res {
|
match res {
|
||||||
|
|
|
@ -610,11 +610,9 @@ where
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub enum Cancelled {
|
pub enum Cancelled {
|
||||||
/// The query was operating on revision R, but there is a pending write to move to revision R+1.
|
/// The query was operating on revision R, but there is a pending write to move to revision R+1.
|
||||||
#[non_exhaustive]
|
|
||||||
PendingWrite,
|
PendingWrite,
|
||||||
|
|
||||||
/// The query was blocked on another thread, and that thread panicked.
|
/// The query was blocked on another thread, and that thread panicked.
|
||||||
#[non_exhaustive]
|
|
||||||
PropagatedPanic,
|
PropagatedPanic,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ use std::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use ide::Cancelled;
|
use ide::Cancelled;
|
||||||
|
use ide_db::base_db::ra_salsa::Cycle;
|
||||||
use lsp_server::{ExtractError, Response, ResponseError};
|
use lsp_server::{ExtractError, Response, ResponseError};
|
||||||
use serde::{de::DeserializeOwned, Serialize};
|
use serde::{de::DeserializeOwned, Serialize};
|
||||||
use stdx::thread::ThreadIntent;
|
use stdx::thread::ThreadIntent;
|
||||||
|
@ -328,7 +329,13 @@ where
|
||||||
if let Some(panic_message) = panic_message {
|
if let Some(panic_message) = panic_message {
|
||||||
message.push_str(": ");
|
message.push_str(": ");
|
||||||
message.push_str(panic_message)
|
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(
|
Ok(lsp_server::Response::new_err(
|
||||||
id,
|
id,
|
||||||
|
|
|
@ -1085,7 +1085,7 @@ fn resolve_proc_macro() {
|
||||||
let sysroot = project_model::Sysroot::discover(
|
let sysroot = project_model::Sysroot::discover(
|
||||||
&AbsPathBuf::assert_utf8(std::env::current_dir().unwrap()),
|
&AbsPathBuf::assert_utf8(std::env::current_dir().unwrap()),
|
||||||
&Default::default(),
|
&Default::default(),
|
||||||
project_model::SysrootQueryMetadata::CargoMetadata,
|
&project_model::SysrootQueryMetadata::default(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let proc_macro_server_path = sysroot.discover_proc_macro_srv().unwrap();
|
let proc_macro_server_path = sysroot.discover_proc_macro_srv().unwrap();
|
||||||
|
|
Loading…
Reference in a new issue