Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
lsp: Skip serializing of params if unit type (#46027)
Michael Barthda53a2b22eea
diff --git a/crates/lsp/src/lsp.rs b/crates/lsp/src/lsp.rsindex 519883818c4..d1ce36c4621 100644--- a/crates/lsp/src/lsp.rs+++ b/crates/lsp/src/lsp.rs@@ -25,6 +25,7 @@ use smol::{};use std::{+ any::TypeId,collections::BTreeSet,ffi::{OsStr, OsString},fmt,@@ -200,14 +201,22 @@ pub enum RequestId {Str(String),}+fn is_unit<T: 'static>(_: &T) -> bool {+ TypeId::of::<T>() == TypeId::of::<()>()+}+/// Language server protocol RPC request message.////// [LSP Specification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#requestMessage)#[derive(Serialize, Deserialize)]-pub struct Request<'a, T> {+pub struct Request<'a, T>+where+ T: 'static,+{jsonrpc: &'static str,id: RequestId,method: &'a str,+ #[serde(default, skip_serializing_if = "is_unit")]params: T,}@@ -245,10 +254,14 @@ enum LspResult<T> {////// [LSP Specification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#notificationMessage)#[derive(Serialize, Deserialize)]-struct Notification<'a, T> {+struct Notification<'a, T>+where+ T: 'static,+{jsonrpc: &'static str,#[serde(borrow)]method: &'a str,+ #[serde(default, skip_serializing_if = "is_unit")]params: T,}