Skip to content

Commit 3db8da6

Browse files
committed
Make clippy::needless-borrow happy
Signed-off-by: hi-rustin <[email protected]>
1 parent b842e57 commit 3db8da6

13 files changed

+133
-133
lines changed

src/cli/self_update.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ fn customize_install(mut opts: InstallOpts<'_>) -> Result<InstallOpts<'_>> {
712712
fn install_bins() -> Result<()> {
713713
let bin_path = utils::cargo_home()?.join("bin");
714714
let this_exe_path = utils::current_exe()?;
715-
let rustup_path = bin_path.join(&format!("rustup{EXE_SUFFIX}"));
715+
let rustup_path = bin_path.join(format!("rustup{EXE_SUFFIX}"));
716716

717717
utils::ensure_dir_exists("bin", &bin_path, &|_: Notification<'_>| {})?;
718718
// NB: Even on Linux we can't just copy the new binary over the (running)
@@ -1088,8 +1088,8 @@ fn parse_new_rustup_version(version: String) -> String {
10881088

10891089
pub(crate) fn prepare_update() -> Result<Option<PathBuf>> {
10901090
let cargo_home = utils::cargo_home()?;
1091-
let rustup_path = cargo_home.join(&format!("bin{MAIN_SEPARATOR}rustup{EXE_SUFFIX}"));
1092-
let setup_path = cargo_home.join(&format!("bin{MAIN_SEPARATOR}rustup-init{EXE_SUFFIX}"));
1091+
let rustup_path = cargo_home.join(format!("bin{MAIN_SEPARATOR}rustup{EXE_SUFFIX}"));
1092+
let setup_path = cargo_home.join(format!("bin{MAIN_SEPARATOR}rustup-init{EXE_SUFFIX}"));
10931093

10941094
if !rustup_path.exists() {
10951095
return Err(CLIError::NotSelfInstalled { p: cargo_home }.into());
@@ -1212,7 +1212,7 @@ pub(crate) fn check_rustup_update() -> Result<()> {
12121212

12131213
pub(crate) fn cleanup_self_updater() -> Result<()> {
12141214
let cargo_home = utils::cargo_home()?;
1215-
let setup = cargo_home.join(&format!("bin/rustup-init{EXE_SUFFIX}"));
1215+
let setup = cargo_home.join(format!("bin/rustup-init{EXE_SUFFIX}"));
12161216

12171217
if setup.exists() {
12181218
utils::remove_file("setup", &setup)?;

src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ impl Cfg {
865865

866866
// Filter out toolchains that don't track a release channel
867867
Ok(toolchains
868-
.filter(|&(_, ref t)| t.as_ref().map(Toolchain::is_tracking).unwrap_or(false))
868+
.filter(|(_, ref t)| t.as_ref().map(Toolchain::is_tracking).unwrap_or(false))
869869
.collect())
870870
}
871871

src/diskio/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ pub(crate) fn perform<F: Fn(usize)>(item: &mut Item, chunk_complete_callback: F)
342342
write_file(&item.full_path, contents, item.mode)
343343
}
344344
FileBuffer::Threaded(ref mut contents) => {
345-
write_file(&item.full_path, &contents, item.mode)
345+
write_file(&item.full_path, contents, item.mode)
346346
}
347347
}
348348
}

src/utils/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ pub(crate) fn create_rustup_home() -> Result<()> {
510510
}
511511

512512
let home = rustup_home_in_user_dir()?;
513-
fs::create_dir_all(&home).context("unable to create ~/.rustup")?;
513+
fs::create_dir_all(home).context("unable to create ~/.rustup")?;
514514

515515
Ok(())
516516
}

tests/cli-inst-interactive.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ fn install_stops_if_rustc_exists() {
529529
.tempdir()
530530
.unwrap();
531531
// Create fake executable
532-
let fake_exe = temp_dir.path().join(&format!("{}{}", "rustc", EXE_SUFFIX));
532+
let fake_exe = temp_dir.path().join(format!("{}{}", "rustc", EXE_SUFFIX));
533533
raw::append_file(&fake_exe, "").unwrap();
534534
let temp_dir_path = temp_dir.path().to_str().unwrap();
535535

@@ -560,7 +560,7 @@ fn install_stops_if_cargo_exists() {
560560
.tempdir()
561561
.unwrap();
562562
// Create fake executable
563-
let fake_exe = temp_dir.path().join(&format!("{}{}", "cargo", EXE_SUFFIX));
563+
let fake_exe = temp_dir.path().join(format!("{}{}", "cargo", EXE_SUFFIX));
564564
raw::append_file(&fake_exe, "").unwrap();
565565
let temp_dir_path = temp_dir.path().to_str().unwrap();
566566

@@ -591,7 +591,7 @@ fn with_no_prompt_install_succeeds_if_rustc_exists() {
591591
.tempdir()
592592
.unwrap();
593593
// Create fake executable
594-
let fake_exe = temp_dir.path().join(&format!("{}{}", "rustc", EXE_SUFFIX));
594+
let fake_exe = temp_dir.path().join(format!("{}{}", "rustc", EXE_SUFFIX));
595595
raw::append_file(&fake_exe, "").unwrap();
596596
let temp_dir_path = temp_dir.path().to_str().unwrap();
597597

tests/cli-misc.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,8 @@ fn rustup_failed_path_search() {
389389
setup(&|config| {
390390
use std::env::consts::EXE_SUFFIX;
391391

392-
let rustup_path = config.exedir.join(&format!("rustup{EXE_SUFFIX}"));
393-
let tool_path = config.exedir.join(&format!("fake_proxy{EXE_SUFFIX}"));
392+
let rustup_path = config.exedir.join(format!("rustup{EXE_SUFFIX}"));
393+
let tool_path = config.exedir.join(format!("fake_proxy{EXE_SUFFIX}"));
394394
utils::hardlink_file(&rustup_path, &tool_path)
395395
.expect("Failed to create fake proxy for test");
396396

@@ -426,8 +426,8 @@ fn rustup_failed_path_search_toolchain() {
426426
setup(&|config| {
427427
use std::env::consts::EXE_SUFFIX;
428428

429-
let rustup_path = config.exedir.join(&format!("rustup{EXE_SUFFIX}"));
430-
let tool_path = config.exedir.join(&format!("cargo-miri{EXE_SUFFIX}"));
429+
let rustup_path = config.exedir.join(format!("rustup{EXE_SUFFIX}"));
430+
let tool_path = config.exedir.join(format!("cargo-miri{EXE_SUFFIX}"));
431431
utils::hardlink_file(&rustup_path, &tool_path)
432432
.expect("Failed to create fake cargo-miri for test");
433433

tests/cli-rustup.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ fn add_target() {
336336
);
337337
expect_ok(config, &["rustup", "default", "nightly"]);
338338
expect_ok(config, &["rustup", "target", "add", clitools::CROSS_ARCH1]);
339-
assert!(config.rustupdir.has(&path));
339+
assert!(config.rustupdir.has(path));
340340
});
341341
}
342342

@@ -378,13 +378,13 @@ fn add_remove_multiple_targets() {
378378
&this_host_triple(),
379379
clitools::CROSS_ARCH1
380380
);
381-
assert!(config.rustupdir.has(&path));
381+
assert!(config.rustupdir.has(path));
382382
let path = format!(
383383
"toolchains/nightly-{}/lib/rustlib/{}/lib/libstd.rlib",
384384
&this_host_triple(),
385385
clitools::CROSS_ARCH2
386386
);
387-
assert!(config.rustupdir.has(&path));
387+
assert!(config.rustupdir.has(path));
388388

389389
expect_ok(
390390
config,
@@ -401,13 +401,13 @@ fn add_remove_multiple_targets() {
401401
&this_host_triple(),
402402
clitools::CROSS_ARCH1
403403
);
404-
assert!(!config.rustupdir.has(&path));
404+
assert!(!config.rustupdir.has(path));
405405
let path = format!(
406406
"toolchains/nightly-{}/lib/rustlib/{}/lib/libstd.rlib",
407407
&this_host_triple(),
408408
clitools::CROSS_ARCH2
409409
);
410-
assert!(!config.rustupdir.has(&path));
410+
assert!(!config.rustupdir.has(path));
411411
});
412412
}
413413

@@ -449,7 +449,7 @@ fn add_target_explicit() {
449449
clitools::CROSS_ARCH1,
450450
],
451451
);
452-
assert!(config.rustupdir.has(&path));
452+
assert!(config.rustupdir.has(path));
453453
});
454454
}
455455

@@ -528,7 +528,7 @@ fn fallback_cargo_calls_correct_rustc() {
528528
let cargo_bin_path = config.cargodir.join("bin");
529529
fs::create_dir_all(&cargo_bin_path).unwrap();
530530
let rustc_path = cargo_bin_path.join(format!("rustc{EXE_SUFFIX}"));
531-
fs::hard_link(&rustup_path, &rustc_path).unwrap();
531+
fs::hard_link(rustup_path, &rustc_path).unwrap();
532532

533533
// Install a custom toolchain and a nightly toolchain for the cargo fallback
534534
let path = config.customdir.join("custom-1");
@@ -1309,7 +1309,7 @@ fn add_component() {
13091309
"toolchains/stable-{}/lib/rustlib/src/rust-src/foo.rs",
13101310
this_host_triple()
13111311
);
1312-
assert!(config.rustupdir.has(&path));
1312+
assert!(config.rustupdir.has(path));
13131313
});
13141314
}
13151315

@@ -1527,7 +1527,7 @@ fn file_override_path_no_options() {
15271527
let cwd = config.current_dir();
15281528
let toolchain_path = cwd.join("ephemeral");
15291529
let toolchain_bin = toolchain_path.join("bin");
1530-
fs::create_dir_all(&toolchain_bin).unwrap();
1530+
fs::create_dir_all(toolchain_bin).unwrap();
15311531

15321532
let toolchain_file = cwd.join("rust-toolchain.toml");
15331533
raw::write_file(
@@ -1575,7 +1575,7 @@ fn file_override_path_xor_channel() {
15751575
let cwd = config.current_dir();
15761576
let toolchain_path = cwd.join("ephemeral");
15771577
let toolchain_bin = toolchain_path.join("bin");
1578-
fs::create_dir_all(&toolchain_bin).unwrap();
1578+
fs::create_dir_all(toolchain_bin).unwrap();
15791579

15801580
let toolchain_file = cwd.join("rust-toolchain.toml");
15811581
raw::write_file(

0 commit comments

Comments
 (0)