From afa8dfc51faa9304e03cb79c84c7e99bd7cf2f42 Mon Sep 17 00:00:00 2001 From: Mathew Horner Date: Sat, 25 May 2024 15:00:15 -0500 Subject: [PATCH] Avoid clone when constructing runnable label. --- src/tools/rust-analyzer/crates/ide/src/runnables.rs | 2 +- .../rust-analyzer/crates/rust-analyzer/src/lsp/to_proto.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tools/rust-analyzer/crates/ide/src/runnables.rs b/src/tools/rust-analyzer/crates/ide/src/runnables.rs index 64ffa59101765..2feea09840fa1 100644 --- a/src/tools/rust-analyzer/crates/ide/src/runnables.rs +++ b/src/tools/rust-analyzer/crates/ide/src/runnables.rs @@ -79,7 +79,7 @@ impl RunnableKind { impl Runnable { // test package::module::testname - pub fn label(&self, target: Option) -> String { + pub fn label(&self, target: Option<&str>) -> String { match &self.kind { RunnableKind::Test { test_id, .. } => format!("test {test_id}"), RunnableKind::TestMod { path } => format!("test-mod {path}"), diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/to_proto.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/to_proto.rs index 1d7062c989774..86368c9eea87f 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/to_proto.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/to_proto.rs @@ -1364,10 +1364,10 @@ pub(crate) fn runnable( ide::RunnableKind::Bin { .. } => workspace_root.clone().map(|it| it.into()), _ => spec.as_ref().map(|it| it.cargo_toml.parent().into()), }; - let target = spec.as_ref().map(|s| s.target.clone()); + let target = spec.as_ref().map(|s| s.target.as_str()); + let label = runnable.label(target); let (cargo_args, executable_args) = CargoTargetSpec::runnable_args(snap, spec, &runnable.kind, &runnable.cfg); - let label = runnable.label(target); let location = location_link(snap, None, runnable.nav)?; Ok(lsp_ext::Runnable {