From b1d600a1ecbf2032ef09d56559111da4382135df Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Mon, 3 May 2021 18:18:45 +0300 Subject: Less panics in the assist resolution --- crates/rust-analyzer/src/handlers.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'crates') 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( )?; 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) -- cgit v1.2.3