Skip to content

Commit

Permalink
Avoid clone when constructing runnable label.
Browse files Browse the repository at this point in the history
  • Loading branch information
mathew-horner committed May 25, 2024
1 parent 56d77b9 commit afa8dfc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/tools/rust-analyzer/crates/ide/src/runnables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl RunnableKind {

impl Runnable {
// test package::module::testname
pub fn label(&self, target: Option<String>) -> 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}"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit afa8dfc

Please sign in to comment.