Unnamed repository; edit this file 'description' to name the repository.
-rw-r--r--crates/rust-analyzer/src/from_proto.rs7
-rw-r--r--crates/rust-analyzer/src/handlers.rs5
2 files changed, 9 insertions, 3 deletions
diff --git a/crates/rust-analyzer/src/from_proto.rs b/crates/rust-analyzer/src/from_proto.rs
index 712d5a9c27..28f3fa2786 100644
--- a/crates/rust-analyzer/src/from_proto.rs
+++ b/crates/rust-analyzer/src/from_proto.rs
@@ -10,7 +10,7 @@ use crate::{
from_json,
global_state::GlobalStateSnapshot,
line_index::{LineIndex, OffsetEncoding},
- lsp_ext, Result,
+ lsp_ext, LspError, Result,
};
pub(crate) fn abs_path(url: &lsp_types::Url) -> Result<AbsPathBuf> {
@@ -85,7 +85,10 @@ pub(crate) fn annotation(
snap: &GlobalStateSnapshot,
code_lens: lsp_types::CodeLens,
) -> Result<Annotation> {
- let data = code_lens.data.unwrap();
+ let data = code_lens.data.ok_or_else(|| LspError {
+ code: lsp_server::ErrorCode::InvalidParams as i32,
+ message: "code lens without data".to_string(),
+ });
let resolve = from_json::<lsp_ext::CodeLensResolveData>("CodeLensResolveData", data)?;
match resolve {
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs
index de96816f44..ed912cb160 100644
--- a/crates/rust-analyzer/src/handlers.rs
+++ b/crates/rust-analyzer/src/handlers.rs
@@ -1038,7 +1038,10 @@ pub(crate) fn handle_code_action_resolve(
let _p = profile::span("handle_code_action_resolve");
let params = match code_action.data.take() {
Some(it) => it,
- None => Err("can't resolve code action without data")?,
+ None => Err(LspError {
+ code: lsp_server::ErrorCode::InvalidParams as i32,
+ message: format!("code action without data"),
+ })?,
};
let file_id = from_proto::file_id(&snap, &params.code_action_params.text_document.uri)?;