From 92da7e9ffa2ebde6b8ccd73c86f58b0570059e42 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov <aleksey.kladov@gmail.com> Date: Sun, 15 Aug 2021 13:24:37 +0300 Subject: [PATCH] internal: optimize compile time cargo llvm-lines shows that path_to_error bloats the code. I don't think I've needed this functionality recently, seems that we've fixed most of the serialization problems. So let's just remove it. Should be easy to add back if we ever need it, and it does make sense to keep the `from_json` function around. --- Cargo.lock | 10 ---------- crates/rust-analyzer/Cargo.toml | 1 - crates/rust-analyzer/src/lib.rs | 5 +++-- 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9d95151da9f..d7d0832bb31 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1315,7 +1315,6 @@ dependencies = [ "rustc-hash", "serde", "serde_json", - "serde_path_to_error", "sourcegen", "stdx", "syntax", @@ -1453,15 +1452,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_path_to_error" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42f6109f0506e20f7e0f910e51a0079acf41da8e0694e6442527c4ddf5a2b158" -dependencies = [ - "serde", -] - [[package]] name = "serde_repr" version = "0.1.7" diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml index 8a18d5801a7..b8355005617 100644 --- a/crates/rust-analyzer/Cargo.toml +++ b/crates/rust-analyzer/Cargo.toml @@ -31,7 +31,6 @@ oorandom = "11.1.2" rustc-hash = "1.1.0" serde = { version = "1.0.106", features = ["derive"] } serde_json = { version = "1.0.48", features = ["preserve_order"] } -serde_path_to_error = "0.1" threadpool = "1.7.1" rayon = "1.5" mimalloc = { version = "0.1.19", default-features = false, optional = true } diff --git a/crates/rust-analyzer/src/lib.rs b/crates/rust-analyzer/src/lib.rs index c8c996f0da5..d29ec512d61 100644 --- a/crates/rust-analyzer/src/lib.rs +++ b/crates/rust-analyzer/src/lib.rs @@ -41,16 +41,17 @@ pub mod config; #[cfg(test)] mod integrated_benchmarks; -use serde::de::DeserializeOwned; use std::fmt; +use serde::de::DeserializeOwned; + pub use crate::{caps::server_capabilities, main_loop::main_loop}; pub type Error = Box<dyn std::error::Error + Send + Sync>; pub type Result<T, E = Error> = std::result::Result<T, E>; pub fn from_json<T: DeserializeOwned>(what: &'static str, json: serde_json::Value) -> Result<T> { - let res = serde_path_to_error::deserialize(&json) + let res = serde_json::from_value(json.clone()) .map_err(|e| format!("Failed to deserialize {}: {}; {}", what, e, json))?; Ok(res) }