From 6997ee915104a6482c1d94fa7196f3bea6b87a08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Fern=C3=A1ndez=20Serrata?= <76864299+Rudxain@users.noreply.github.com> Date: Tue, 9 Jul 2024 05:34:28 -0400 Subject: [PATCH] `&Option` -> `Option<&T>` (#11091) * refactor `starting_request_args` to only `ref` non-`Copy` * refactor `needs_recompile` to only `ref` non-`Copy` * refactor `add_workspace_folder` to only `ref` `Some` --------- Co-authored-by: Rudxain --- helix-dap/src/client.rs | 4 ++-- helix-loader/src/grammar.rs | 4 ++-- helix-lsp/src/client.rs | 11 +++++++---- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/helix-dap/src/client.rs b/helix-dap/src/client.rs index 2f5b3d0fc..ed4515fe9 100644 --- a/helix-dap/src/client.rs +++ b/helix-dap/src/client.rs @@ -157,8 +157,8 @@ async fn get_port() -> Option { ) } - pub fn starting_request_args(&self) -> &Option { - &self.starting_request_args + pub fn starting_request_args(&self) -> Option<&Value> { + self.starting_request_args.as_ref() } pub async fn tcp_process( diff --git a/helix-loader/src/grammar.rs b/helix-loader/src/grammar.rs index 7977c6df8..99e911544 100644 --- a/helix-loader/src/grammar.rs +++ b/helix-loader/src/grammar.rs @@ -422,7 +422,7 @@ fn build_tree_sitter_library( } } - let recompile = needs_recompile(&library_path, &parser_path, &scanner_path) + let recompile = needs_recompile(&library_path, &parser_path, scanner_path.as_ref()) .context("Failed to compare source and binary timestamps")?; if !recompile { @@ -568,7 +568,7 @@ fn build_tree_sitter_library( fn needs_recompile( lib_path: &Path, parser_c_path: &Path, - scanner_path: &Option, + scanner_path: Option<&PathBuf>, ) -> Result { if !lib_path.exists() { return Ok(true); diff --git a/helix-lsp/src/client.rs b/helix-lsp/src/client.rs index 0a822c5b3..643aa9a26 100644 --- a/helix-lsp/src/client.rs +++ b/helix-lsp/src/client.rs @@ -123,7 +123,7 @@ pub fn try_add_doc( { client.add_workspace_folder( root_uri, - &workspace_folders_caps.change_notifications, + workspace_folders_caps.change_notifications.as_ref(), ); } }); @@ -136,7 +136,10 @@ pub fn try_add_doc( .and_then(|cap| cap.workspace_folders.as_ref()) .filter(|cap| cap.supported.unwrap_or(false)) { - self.add_workspace_folder(root_uri, &workspace_folders_caps.change_notifications); + self.add_workspace_folder( + root_uri, + workspace_folders_caps.change_notifications.as_ref(), + ); true } else { // the server doesn't support multi workspaces, we need a new client @@ -147,7 +150,7 @@ pub fn try_add_doc( fn add_workspace_folder( &self, root_uri: Option, - change_notifications: &Option>, + change_notifications: Option<&OneOf>, ) { // root_uri is None just means that there isn't really any LSP workspace // associated with this file. For servers that support multiple workspaces @@ -162,7 +165,7 @@ fn add_workspace_folder( self.workspace_folders .lock() .push(workspace_for_uri(root_uri.clone())); - if &Some(OneOf::Left(false)) == change_notifications { + if Some(&OneOf::Left(false)) == change_notifications { // server specifically opted out of DidWorkspaceChange notifications // let's assume the server will request the workspace folders itself // and that we can therefore reuse the client (but are done now)