diff options
Diffstat (limited to 'crates/gen_lsp_server/src/msg.rs')
-rw-r--r-- | crates/gen_lsp_server/src/msg.rs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/crates/gen_lsp_server/src/msg.rs b/crates/gen_lsp_server/src/msg.rs index 1d39ba4bc..8138b84eb 100644 --- a/crates/gen_lsp_server/src/msg.rs +++ b/crates/gen_lsp_server/src/msg.rs | |||
@@ -3,7 +3,6 @@ use std::io::{BufRead, Write}; | |||
3 | use lsp_types::{notification::Notification, request::Request}; | 3 | use lsp_types::{notification::Notification, request::Request}; |
4 | use serde::{Deserialize, Serialize}; | 4 | use serde::{Deserialize, Serialize}; |
5 | use serde_json::{from_str, from_value, to_string, to_value, Value}; | 5 | use serde_json::{from_str, from_value, to_string, to_value, Value}; |
6 | use failure::{bail, format_err}; | ||
7 | 6 | ||
8 | use crate::Result; | 7 | use crate::Result; |
9 | 8 | ||
@@ -175,7 +174,7 @@ fn read_msg_text(inp: &mut impl BufRead) -> Result<Option<String>> { | |||
175 | return Ok(None); | 174 | return Ok(None); |
176 | } | 175 | } |
177 | if !buf.ends_with("\r\n") { | 176 | if !buf.ends_with("\r\n") { |
178 | bail!("malformed header: {:?}", buf); | 177 | Err(format!("malformed header: {:?}", buf))?; |
179 | } | 178 | } |
180 | let buf = &buf[..buf.len() - 2]; | 179 | let buf = &buf[..buf.len() - 2]; |
181 | if buf.is_empty() { | 180 | if buf.is_empty() { |
@@ -184,12 +183,12 @@ fn read_msg_text(inp: &mut impl BufRead) -> Result<Option<String>> { | |||
184 | let mut parts = buf.splitn(2, ": "); | 183 | let mut parts = buf.splitn(2, ": "); |
185 | let header_name = parts.next().unwrap(); | 184 | let header_name = parts.next().unwrap(); |
186 | let header_value = | 185 | let header_value = |
187 | parts.next().ok_or_else(|| format_err!("malformed header: {:?}", buf))?; | 186 | parts.next().ok_or_else(|| format!("malformed header: {:?}", buf))?; |
188 | if header_name == "Content-Length" { | 187 | if header_name == "Content-Length" { |
189 | size = Some(header_value.parse::<usize>()?); | 188 | size = Some(header_value.parse::<usize>()?); |
190 | } | 189 | } |
191 | } | 190 | } |
192 | let size = size.ok_or_else(|| format_err!("no Content-Length"))?; | 191 | let size = size.ok_or("no Content-Length")?; |
193 | let mut buf = buf.into_bytes(); | 192 | let mut buf = buf.into_bytes(); |
194 | buf.resize(size, 0); | 193 | buf.resize(size, 0); |
195 | inp.read_exact(&mut buf)?; | 194 | inp.read_exact(&mut buf)?; |