Auto merge of #18065 - Veykril:catchy-diagnostics, r=Veykril
fix: Catch panics from diagnostics computation
This commit is contained in:
commit
56fde6ef41
@ -4,6 +4,7 @@
|
|||||||
use std::{
|
use std::{
|
||||||
fmt,
|
fmt,
|
||||||
ops::Div as _,
|
ops::Div as _,
|
||||||
|
panic::AssertUnwindSafe,
|
||||||
time::{Duration, Instant},
|
time::{Duration, Instant},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -552,23 +553,33 @@ impl GlobalState {
|
|||||||
let fetch_semantic =
|
let fetch_semantic =
|
||||||
self.vfs_done && self.fetch_workspaces_queue.last_op_result().is_some();
|
self.vfs_done && self.fetch_workspaces_queue.last_op_result().is_some();
|
||||||
move |sender| {
|
move |sender| {
|
||||||
let diags = fetch_native_diagnostics(
|
// We aren't observing the semantics token cache here
|
||||||
|
let snapshot = AssertUnwindSafe(&snapshot);
|
||||||
|
let Ok(diags) = std::panic::catch_unwind(|| {
|
||||||
|
fetch_native_diagnostics(
|
||||||
&snapshot,
|
&snapshot,
|
||||||
subscriptions.clone(),
|
subscriptions.clone(),
|
||||||
slice.clone(),
|
slice.clone(),
|
||||||
NativeDiagnosticsFetchKind::Syntax,
|
NativeDiagnosticsFetchKind::Syntax,
|
||||||
);
|
)
|
||||||
|
}) else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
sender
|
sender
|
||||||
.send(Task::Diagnostics(DiagnosticsTaskKind::Syntax(generation, diags)))
|
.send(Task::Diagnostics(DiagnosticsTaskKind::Syntax(generation, diags)))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
if fetch_semantic {
|
if fetch_semantic {
|
||||||
let diags = fetch_native_diagnostics(
|
let Ok(diags) = std::panic::catch_unwind(|| {
|
||||||
|
fetch_native_diagnostics(
|
||||||
&snapshot,
|
&snapshot,
|
||||||
subscriptions,
|
subscriptions.clone(),
|
||||||
slice,
|
slice.clone(),
|
||||||
NativeDiagnosticsFetchKind::Semantic,
|
NativeDiagnosticsFetchKind::Semantic,
|
||||||
);
|
)
|
||||||
|
}) else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
sender
|
sender
|
||||||
.send(Task::Diagnostics(DiagnosticsTaskKind::Semantic(
|
.send(Task::Diagnostics(DiagnosticsTaskKind::Semantic(
|
||||||
generation, diags,
|
generation, diags,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user