Avoid clone when constructing runnable label. · rust-lang/rust@afa8dfc

File tree

2 files changed

lines changed

  • src/tools/rust-analyzer/crates

2 files changed

lines changed

Original file line numberDiff line numberDiff line change

@@ -79,7 +79,7 @@ impl RunnableKind {

7979
8080

impl Runnable {

8181

// test package::module::testname

82-

pub fn label(&self, target: Option<String>) -> String {

82+

pub fn label(&self, target: Option<&str>) -> String {

8383

match &self.kind {

8484

RunnableKind::Test { test_id, .. } => format!("test {test_id}"),

8585

RunnableKind::TestMod { path } => format!("test-mod {path}"),

Original file line numberDiff line numberDiff line change

@@ -1364,10 +1364,10 @@ pub(crate) fn runnable(

13641364

ide::RunnableKind::Bin { .. } => workspace_root.clone().map(|it| it.into()),

13651365

_ => spec.as_ref().map(|it| it.cargo_toml.parent().into()),

13661366

};

1367-

let target = spec.as_ref().map(|s| s.target.clone());

1367+

let target = spec.as_ref().map(|s| s.target.as_str());

1368+

let label = runnable.label(target);

13681369

let (cargo_args, executable_args) =

13691370

CargoTargetSpec::runnable_args(snap, spec, &runnable.kind, &runnable.cfg);

1370-

let label = runnable.label(target);

13711371

let location = location_link(snap, None, runnable.nav)?;

13721372
13731373

Ok(lsp_ext::Runnable {