on master help sign in
Remove some more unwraps
24f0309Blaž Hrastnik
helix-lsp/src/client.rs+3−3
@@ -271,8 +271,8 @@ impl Client {
271 // -------------------------------------------------------------------------------------------
271 // -------------------------------------------------------------------------------------------
272
272
273 pub(crate) async fn initialize(&self) -> Result<lsp::InitializeResult> {
273 pub(crate) async fn initialize(&self) -> Result<lsp::InitializeResult> {
274− if self.config.is_some() {
274+ if let Some(config) = &self.config {
275− log::info!("Using custom LSP config: {}", self.config.as_ref().unwrap());
275+ log::info!("Using custom LSP config: {}", config);
276 }
276 }
277
277
278 #[allow(deprecated)]
278 #[allow(deprecated)]
@@ -896,8 +896,8 @@ impl Client {
896 Some(lsp::OneOf::Left(true)) | Some(lsp::OneOf::Right(_)) => (),
896 Some(lsp::OneOf::Left(true)) | Some(lsp::OneOf::Right(_)) => (),
897 // None | Some(false)
897 // None | Some(false)
898 _ => {
898 _ => {
899+ log::warn!("rename_symbol failed: The server does not support rename");
899 let err = "The server does not support rename";
900 let err = "The server does not support rename";
900− log::warn!("rename_symbol failed: {}", err);
901 return Err(anyhow!(err));
901 return Err(anyhow!(err));
902 }
902 }
903 };
903 };
helix-lsp/src/jsonrpc.rs+2−2
@@ -310,7 +310,7 @@ fn method_call_serialize() {
310 id: Id::Num(1),
310 id: Id::Num(1),
311 };
311 };
312
312
313− let serialized = serde_json::to_string(&m).unwrap();
313+ let serialized = serde_json::json!(&m);
314 assert_eq!(
314 assert_eq!(
315 serialized,
315 serialized,
316 r#"{"jsonrpc":"2.0","method":"update","params":[1,2],"id":1}"#
316 r#"{"jsonrpc":"2.0","method":"update","params":[1,2],"id":1}"#
@@ -327,7 +327,7 @@ fn notification_serialize() {
327 params: Params::Array(vec![Value::from(1), Value::from(2)]),
327 params: Params::Array(vec![Value::from(1), Value::from(2)]),
328 };
328 };
329
329
330− let serialized = serde_json::to_string(&n).unwrap();
330+ let serialized = serde_json::json!(&n);
331 assert_eq!(
331 assert_eq!(
332 serialized,
332 serialized,
333 r#"{"jsonrpc":"2.0","method":"update","params":[1,2]}"#
333 r#"{"jsonrpc":"2.0","method":"update","params":[1,2]}"#