diff options
author | Kirill Bulatov <[email protected]> | 2021-05-03 16:18:45 +0100 |
---|---|---|
committer | Kirill Bulatov <[email protected]> | 2021-05-03 16:18:45 +0100 |
commit | b1d600a1ecbf2032ef09d56559111da4382135df (patch) | |
tree | 0206d3ecf3411a2e02d41fdb03ea77e671c88c26 /crates | |
parent | 28293d370ffc4270bb6244579166f0df18962951 (diff) |
Less panics in the assist resolution
Diffstat (limited to 'crates')
-rw-r--r-- | crates/rust-analyzer/src/handlers.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index 304951b7d..77faf7579 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( | |||
1077 | )?; | 1077 | )?; |
1078 | 1078 | ||
1079 | let assist = &assists[params.index]; | 1079 | let assist = &assists[params.index]; |
1080 | assert!(assist.id.0 == params.id); | 1080 | if assist.id.0 != params.id || assist.id.1 != assist_kind { |
1081 | assert!(assist.id.1 == assist_kind); | 1081 | return Err(LspError::new( |
1082 | ErrorCode::InvalidParams as i32, | ||
1083 | format!( | ||
1084 | "Failed to find exactly the same assist at index {} for the resolve parameters given. Expected id and kind: {}, {:?}, actual id: {:?}.", | ||
1085 | params.index, params.id, assist_kind, assist.id | ||
1086 | ), | ||
1087 | ) | ||
1088 | .into()); | ||
1089 | } | ||
1082 | let edit = to_proto::code_action(&snap, assist.clone(), None)?.edit; | 1090 | let edit = to_proto::code_action(&snap, assist.clone(), None)?.edit; |
1083 | code_action.edit = edit; | 1091 | code_action.edit = edit; |
1084 | Ok(code_action) | 1092 | Ok(code_action) |