Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't use serde-derive in the rls shim #113556

Merged
merged 1 commit into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3021,7 +3021,6 @@ dependencies = [
name = "rls"
version = "2.0.0"
dependencies = [
"serde",
"serde_json",
]

Expand Down
1 change: 0 additions & 1 deletion src/tools/rls/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ edition = "2021"
license = "Apache-2.0/MIT"

[dependencies]
serde = { version = "1.0.143", features = ["derive"] }
serde_json = "1.0.83"
9 changes: 5 additions & 4 deletions src/tools/rls/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -21,7 +21,6 @@ fn main() {
}
}

#[derive(Deserialize)]
struct Message {
method: Option<String>,
}
Expand Down Expand Up @@ -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()),
}
}
Expand Down