diff options
| author | Josh Stone <jistone@redhat.com> | 2023-07-10 14:53:57 -0700 |
|---|---|---|
| committer | Josh Stone <jistone@redhat.com> | 2023-07-10 14:53:57 -0700 |
| commit | dd5fa7d9b3176f2d922bf52a34a86847adaaab4c (patch) | |
| tree | 2a713c993d7accd20f07cb8cc264141ff4b47695 | |
| parent | 05b82e551e781154ad2af8a72f34712e97206859 (diff) | |
| download | rust-dd5fa7d9b3176f2d922bf52a34a86847adaaab4c.tar.gz rust-dd5fa7d9b3176f2d922bf52a34a86847adaaab4c.zip | |
Don't use serde-derive in the rls shim
The already-small RLS shim can get a little smaller, and faster to build, if we drop the serde-derive dependency and decode the one "method" field it needs manually from `serde_json::Value`.
| -rw-r--r-- | Cargo.lock | 1 | ||||
| -rw-r--r-- | src/tools/rls/Cargo.toml | 1 | ||||
| -rw-r--r-- | src/tools/rls/src/main.rs | 9 |
3 files changed, 5 insertions, 6 deletions
diff --git a/Cargo.lock b/Cargo.lock index 96eda77abb2..a1bbc1dca76 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3021,7 +3021,6 @@ dependencies = [ name = "rls" version = "2.0.0" dependencies = [ - "serde", "serde_json", ] diff --git a/src/tools/rls/Cargo.toml b/src/tools/rls/Cargo.toml index b84647eb332..b7aa659c25a 100644 --- a/src/tools/rls/Cargo.toml +++ b/src/tools/rls/Cargo.toml @@ -5,5 +5,4 @@ edition = "2021" license = "Apache-2.0/MIT" [dependencies] -serde = { version = "1.0.143", features = ["derive"] } serde_json = "1.0.83" diff --git a/src/tools/rls/src/main.rs b/src/tools/rls/src/main.rs index f96f1325d96..d7be108e89c 100644 --- a/src/tools/rls/src/main.rs +++ b/src/tools/rls/src/main.rs @@ -3,7 +3,7 @@ //! This is a small stub that replaces RLS to alert the user that RLS is no //! longer available. -use serde::Deserialize; +use serde_json::Value; use std::error::Error; use std::io::BufRead; use std::io::Write; @@ -21,7 +21,6 @@ fn main() { } } -#[derive(Deserialize)] struct Message { method: Option<String>, } @@ -88,8 +87,10 @@ fn read_message_raw<R: BufRead>(reader: &mut R) -> Result<String, Box<dyn Error> fn read_message<R: BufRead>(reader: &mut R) -> Result<Message, Box<dyn Error>> { let m = read_message_raw(reader)?; - match serde_json::from_str(&m) { - Ok(m) => Ok(m), + match serde_json::from_str::<Value>(&m) { + Ok(message) => Ok(Message { + method: message.get("method").and_then(|value| value.as_str().map(String::from)), + }), Err(e) => Err(format!("failed to parse message {m}\n{e}").into()), } } |
