Description: avoid not-in-Debian crate sonic-rs This essentially reverts upstream git commit e4c5388 Author: Jonas Smedegaard Forwarded: not-needed Last-Update: 2025-12-08 --- This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ --- a/Cargo.toml +++ b/Cargo.toml @@ -53,7 +53,6 @@ tokio-stream = "0.1.18" toml = "1.1" termina = "0.3" -sonic-rs = "0.5" globset = "0.4" etcetera = "0.11" arc-swap = "1.9" --- a/helix-dap/Cargo.toml +++ b/helix-dap/Cargo.toml @@ -28,4 +28,3 @@ futures-executor.workspace = true futures-util.workspace = true tokio-stream.workspace = true -sonic-rs.workspace = true --- a/helix-dap/src/lib.rs +++ b/helix-dap/src/lib.rs @@ -13,7 +13,7 @@ #[derive(Error, Debug)] pub enum Error { #[error("failed to parse: {0}")] - Parse(Box), + Parse(#[from] serde_json::Error), #[error("IO Error: {0}")] IO(#[from] std::io::Error), #[error("request {0} timed out")] @@ -29,18 +29,6 @@ } pub type Result = core::result::Result; -impl From for Error { - fn from(value: serde_json::Error) -> Self { - Self::Parse(Box::new(value)) - } -} - -impl From for Error { - fn from(value: sonic_rs::Error) -> Self { - Self::Parse(Box::new(value)) - } -} - #[derive(Debug)] pub enum Request { RunInTerminal(::Arguments), --- a/helix-dap/src/transport.rs +++ b/helix-dap/src/transport.rs @@ -125,14 +125,12 @@ info!("[{}] <- DAP {}", id, msg); - // NOTE: We avoid using `?` here, since it would return early on error - // and skip clearing `content`. By returning the result directly instead, - // we ensure `content.clear()` is always called. - let output = sonic_rs::from_slice(content).map_err(Into::into); + // try parsing as output (server response) or call (server request) + let output: serde_json::Result = serde_json::from_str(msg); content.clear(); - output + Ok(output?) } async fn recv_server_error( --- a/helix-lsp/Cargo.toml +++ b/helix-lsp/Cargo.toml @@ -32,4 +32,3 @@ arc-swap = "1" slotmap.workspace = true thiserror.workspace = true -sonic-rs.workspace = true --- a/helix-lsp/src/lib.rs +++ b/helix-lsp/src/lib.rs @@ -39,7 +39,7 @@ #[error("protocol error: {0}")] Rpc(#[from] jsonrpc::Error), #[error("failed to parse: {0}")] - Parse(Box), + Parse(#[from] serde_json::Error), #[error("IO Error: {0}")] IO(#[from] std::io::Error), #[error("request {0} timed out")] @@ -54,18 +54,6 @@ Other(#[from] anyhow::Error), } -impl From for Error { - fn from(value: serde_json::Error) -> Self { - Self::Parse(Box::new(value)) - } -} - -impl From for Error { - fn from(value: sonic_rs::Error) -> Self { - Self::Parse(Box::new(value)) - } -} - #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] pub enum OffsetEncoding { /// UTF-8 code units aka bytes --- a/helix-lsp/src/transport.rs +++ b/helix-lsp/src/transport.rs @@ -111,7 +111,7 @@ buffer.clear(); if reader.read_line(buffer).await? == 0 { return Err(Error::StreamClosed); - } + }; // debug!("<- header {:?}", buffer); @@ -146,14 +146,12 @@ info!("{language_server_name} <- {msg}"); - // NOTE: We avoid using `?` here, since it would return early on error - // and skip clearing `content`. By returning the result directly instead, - // we ensure `content.clear()` is always called. - let output = sonic_rs::from_slice(content).map_err(Into::into); + // try parsing as output (server response) or call (server request) + let output: serde_json::Result = serde_json::from_str(msg); content.clear(); - output + Ok(output?) } async fn recv_server_error(