Convenience wrapper around [`catch_panic`] for closures that capture `&self` or other non-[`UnwindSafe`] references. Wraps `f` in [`AssertUnwindSafe`] before forwarding to [`catch_panic`]. This is safe in our context because a panic during LSP handling never leaves shared state in an inconsistent state (the worst case is a stale cache entry).
(
label: &str,
uri: &str,
position: Option<Position>,
f: impl FnOnce() -> T,
)
| 164 | /// during LSP handling never leaves shared state in an inconsistent |
| 165 | /// state (the worst case is a stale cache entry). |
| 166 | pub(crate) fn catch_panic_unwind_safe<T>( |
| 167 | label: &str, |
| 168 | uri: &str, |
| 169 | position: Option<Position>, |
| 170 | f: impl FnOnce() -> T, |
| 171 | ) -> Option<T> { |
| 172 | catch_panic(label, uri, position, AssertUnwindSafe(f)) |
| 173 | } |
| 174 | |
| 175 | /// Convert a filesystem path to a properly percent-encoded `file://` URI string. |
| 176 | /// |
no test coverage detected