about summary refs log tree commit diff
diff options
context:
space:
mode:
authorKirill Bulatov <mail4score@gmail.com>2021-05-03 18:18:45 +0300
committerKirill Bulatov <mail4score@gmail.com>2021-05-03 18:18:45 +0300
commitb1d600a1ecbf2032ef09d56559111da4382135df (patch)
tree0206d3ecf3411a2e02d41fdb03ea77e671c88c26
parent28293d370ffc4270bb6244579166f0df18962951 (diff)
downloadrust-b1d600a1ecbf2032ef09d56559111da4382135df.tar.gz
rust-b1d600a1ecbf2032ef09d56559111da4382135df.zip
Less panics in the assist resolution
-rw-r--r--crates/rust-analyzer/src/handlers.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs
index 304951b7d23..77faf757935 100644
--- a/crates/rust-analyzer/src/handlers.rs
+++ b/crates/rust-analyzer/src/handlers.rs
@@ -1077,8 +1077,16 @@ pub(crate) fn handle_code_action_resolve(
     )?;
 
     let assist = &assists[params.index];
-    assert!(assist.id.0 == params.id);
-    assert!(assist.id.1 == assist_kind);
+    if assist.id.0 != params.id || assist.id.1 != assist_kind {
+        return Err(LspError::new(
+            ErrorCode::InvalidParams as i32,
+            format!(
+                "Failed to find exactly the same assist at index {} for the resolve parameters given. Expected id and kind: {}, {:?}, actual id: {:?}.",
+                params.index, params.id, assist_kind, assist.id
+            ),
+        )
+        .into());
+    }
     let edit = to_proto::code_action(&snap, assist.clone(), None)?.edit;
     code_action.edit = edit;
     Ok(code_action)