Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf7ca8a6

Browse files
committed
Auto merge of#17296 - mathew-horner:no-clone-target, r=Veykril
Avoid clone when constructing runnable label.I stumbled across this when reading this code. This seems like an unnecessary allocation (though likely small?)
2 parentsbd9cc02 +afa8dfc commitf7ca8a6

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

‎src/tools/rust-analyzer/crates/ide/src/runnables.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl RunnableKind {
7979

8080
implRunnable{
8181
// test package::module::testname
82-
pubfnlabel(&self,target:Option<String>) ->String{
82+
pubfnlabel(&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}"),

‎src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/to_proto.rs‎

Lines changed: 2 additions & 2 deletions
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{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp