mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 21:43:37 +00:00
Auto merge of #18065 - Veykril:catchy-diagnostics, r=Veykril
fix: Catch panics from diagnostics computation
This commit is contained in:
commit
e09dabf1f3
1 changed files with 23 additions and 12 deletions
|
@ -4,6 +4,7 @@
|
|||
use std::{
|
||||
fmt,
|
||||
ops::Div as _,
|
||||
panic::AssertUnwindSafe,
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
|
||||
|
@ -552,23 +553,33 @@ impl GlobalState {
|
|||
let fetch_semantic =
|
||||
self.vfs_done && self.fetch_workspaces_queue.last_op_result().is_some();
|
||||
move |sender| {
|
||||
let diags = fetch_native_diagnostics(
|
||||
&snapshot,
|
||||
subscriptions.clone(),
|
||||
slice.clone(),
|
||||
NativeDiagnosticsFetchKind::Syntax,
|
||||
);
|
||||
// We aren't observing the semantics token cache here
|
||||
let snapshot = AssertUnwindSafe(&snapshot);
|
||||
let Ok(diags) = std::panic::catch_unwind(|| {
|
||||
fetch_native_diagnostics(
|
||||
&snapshot,
|
||||
subscriptions.clone(),
|
||||
slice.clone(),
|
||||
NativeDiagnosticsFetchKind::Syntax,
|
||||
)
|
||||
}) else {
|
||||
return;
|
||||
};
|
||||
sender
|
||||
.send(Task::Diagnostics(DiagnosticsTaskKind::Syntax(generation, diags)))
|
||||
.unwrap();
|
||||
|
||||
if fetch_semantic {
|
||||
let diags = fetch_native_diagnostics(
|
||||
&snapshot,
|
||||
subscriptions,
|
||||
slice,
|
||||
NativeDiagnosticsFetchKind::Semantic,
|
||||
);
|
||||
let Ok(diags) = std::panic::catch_unwind(|| {
|
||||
fetch_native_diagnostics(
|
||||
&snapshot,
|
||||
subscriptions.clone(),
|
||||
slice.clone(),
|
||||
NativeDiagnosticsFetchKind::Semantic,
|
||||
)
|
||||
}) else {
|
||||
return;
|
||||
};
|
||||
sender
|
||||
.send(Task::Diagnostics(DiagnosticsTaskKind::Semantic(
|
||||
generation, diags,
|
||||
|
|
Loading…
Reference in a new issue