Update salsa

This commit is contained in:
Lukas Wirth 2025-04-29 19:25:11 +02:00
parent a87177310f
commit 9fa647c129
8 changed files with 75 additions and 33 deletions

View file

@ -7,6 +7,7 @@ use std::{cell::RefCell, fs::read_to_string, panic::AssertUnwindSafe, path::Path
use hir::{ChangeWithProcMacros, Crate};
use ide::{AnalysisHost, DiagnosticCode, DiagnosticsConfig};
use ide_db::base_db;
use itertools::Either;
use paths::Utf8PathBuf;
use profile::StopWatch;
@ -310,7 +311,7 @@ impl flags::RustcTests {
let tester = AssertUnwindSafe(&mut tester);
let p = p.clone();
move || {
let _guard = stdx::panic_context::enter(p.display().to_string());
let _guard = base_db::DbPanicContext::enter(p.display().to_string());
{ tester }.0.test(p);
}
}) {

View file

@ -5,7 +5,7 @@ use std::mem;
use cargo_metadata::PackageId;
use ide::FileId;
use ide_db::FxHashMap;
use ide_db::{FxHashMap, base_db::DbPanicContext};
use itertools::Itertools;
use rustc_hash::FxHashSet;
use stdx::iter_eq_by;
@ -215,7 +215,7 @@ pub(crate) fn fetch_native_diagnostics(
kind: NativeDiagnosticsFetchKind,
) -> Vec<(FileId, Vec<lsp_types::Diagnostic>)> {
let _p = tracing::info_span!("fetch_native_diagnostics").entered();
let _ctx = stdx::panic_context::enter("fetch_native_diagnostics".to_owned());
let _ctx = DbPanicContext::enter("fetch_native_diagnostics".to_owned());
// the diagnostics produced may point to different files not requested by the concrete request,
// put those into here and filter later

View file

@ -4,7 +4,10 @@ use std::{
panic, thread,
};
use ide_db::base_db::salsa::{self, Cancelled};
use ide_db::base_db::{
DbPanicContext,
salsa::{self, Cancelled},
};
use lsp_server::{ExtractError, Response, ResponseError};
use serde::{Serialize, de::DeserializeOwned};
use stdx::thread::ThreadIntent;
@ -56,7 +59,7 @@ impl RequestDispatcher<'_> {
tracing::info_span!("request", method = ?req.method, "request_id" = ?req.id).entered();
tracing::debug!(?params);
let result = {
let _pctx = stdx::panic_context::enter(panic_context);
let _pctx = DbPanicContext::enter(panic_context);
f(self.global_state, params)
};
if let Ok(response) = result_to_response::<R>(req.id, result) {
@ -86,7 +89,7 @@ impl RequestDispatcher<'_> {
let global_state_snapshot = self.global_state.snapshot();
let result = panic::catch_unwind(move || {
let _pctx = stdx::panic_context::enter(panic_context);
let _pctx = DbPanicContext::enter(panic_context);
f(global_state_snapshot, params)
});
@ -257,7 +260,7 @@ impl RequestDispatcher<'_> {
}
.spawn(intent, move || {
let result = panic::catch_unwind(move || {
let _pctx = stdx::panic_context::enter(panic_context);
let _pctx = DbPanicContext::enter(panic_context);
f(world, params)
});
match thread_result_to_response::<R>(req.id.clone(), result) {
@ -421,11 +424,8 @@ impl NotificationDispatcher<'_> {
tracing::debug!(?params);
let _pctx = stdx::panic_context::enter(format!(
"\nversion: {}\nnotification: {}",
version(),
N::METHOD
));
let _pctx =
DbPanicContext::enter(format!("\nversion: {}\nnotification: {}", version(), N::METHOD));
if let Err(e) = f(self.global_state, params) {
tracing::error!(handler = %N::METHOD, error = %e, "notification handler failed");
}