Unnamed repository; edit this file 'description' to name the repository.
Auto merge of #15180 - alibektas:15176, r=Veykril
Purge of unwraps Removes unnecessary unwraps that I have overlooked in #15101 ( fixes #15176 )
bors 2023-06-30
parent f96442a · parent cfbeb66 · commit 7a3991a
-rw-r--r--crates/rust-analyzer/src/handlers/request.rs27
1 files changed, 13 insertions, 14 deletions
diff --git a/crates/rust-analyzer/src/handlers/request.rs b/crates/rust-analyzer/src/handlers/request.rs
index b103341f3c..69799a54cb 100644
--- a/crates/rust-analyzer/src/handlers/request.rs
+++ b/crates/rust-analyzer/src/handlers/request.rs
@@ -2039,20 +2039,19 @@ fn to_url(path: VfsPath) -> Option<Url> {
}
fn resource_ops_supported(config: &Config, kind: ResourceOperationKind) -> anyhow::Result<()> {
- let ctn = config
- .caps()
- .workspace
- .as_ref()
- .unwrap()
- .workspace_edit
- .as_ref()
- .unwrap()
- .resource_operations
- .as_ref()
- .unwrap()
- .contains(&kind);
-
- if !ctn {
+ #[rustfmt::skip]
+ let resops = (|| {
+ config
+ .caps()
+ .workspace
+ .as_ref()?
+ .workspace_edit
+ .as_ref()?
+ .resource_operations
+ .as_ref()
+ })();
+
+ if !matches!(resops, Some(resops) if resops.contains(&kind)) {
return Err(LspError::new(
ErrorCode::RequestFailed as i32,
format!(