Skip to content

Commit dc65020

Browse files
authored
Apply clippy suggestions from Rust 1.74 (#3497)
1 parent ca6ece7 commit dc65020

File tree

6 files changed

+20
-24
lines changed

6 files changed

+20
-24
lines changed

src/cli/rustup_mode.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ pub(crate) fn cli() -> Command {
357357
.subcommand(
358358
Command::new("update")
359359
.about("Update Rust toolchains and rustup")
360-
.aliases(&["upgrade", "up"])
360+
.aliases(["upgrade", "up"])
361361
.after_help(UPDATE_HELP)
362362
.arg(
363363
Arg::new("toolchain")
@@ -413,7 +413,7 @@ pub(crate) fn cli() -> Command {
413413
.subcommand(
414414
Command::new("install")
415415
.about("Install or update a given toolchain")
416-
.aliases(&["update", "add"])
416+
.aliases(["update", "add"])
417417
.arg(
418418
Arg::new("toolchain")
419419
.help(OFFICIAL_TOOLCHAIN_ARG_HELP)
@@ -727,7 +727,7 @@ pub(crate) fn cli() -> Command {
727727
.arg(Arg::new("topic").help(TOPIC_ARG_HELP))
728728
.group(
729729
ArgGroup::new("page").args(
730-
&DOCS_DATA
730+
DOCS_DATA
731731
.iter()
732732
.map(|(name, _, _)| *name)
733733
.collect::<Vec<_>>(),

src/cli/self_update.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ fn install_bins() -> Result<()> {
750750

751751
pub(crate) fn install_proxies() -> Result<()> {
752752
let bin_path = utils::cargo_home()?.join("bin");
753-
let rustup_path = bin_path.join(&format!("rustup{EXE_SUFFIX}"));
753+
let rustup_path = bin_path.join(format!("rustup{EXE_SUFFIX}"));
754754

755755
let rustup = Handle::from_path(&rustup_path)?;
756756

@@ -965,7 +965,7 @@ pub(crate) fn uninstall(no_prompt: bool) -> Result<utils::ExitCode> {
965965

966966
let cargo_home = utils::cargo_home()?;
967967

968-
if !cargo_home.join(&format!("bin/rustup{EXE_SUFFIX}")).exists() {
968+
if !cargo_home.join(format!("bin/rustup{EXE_SUFFIX}")).exists() {
969969
return Err(CLIError::NotSelfInstalled { p: cargo_home }.into());
970970
}
971971

src/currentprocess/homethunk.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
/// Adapts currentprocess to the trait home::Env
22
use std::ffi::OsString;
33
use std::io;
4-
#[cfg(feature = "test")]
5-
use std::ops::Deref;
64
use std::path::PathBuf;
75

86
use home::env as home;
@@ -42,10 +40,10 @@ impl home::Env for TestProcess {
4240
self.var("HOME").ok().map(|v| v.into())
4341
}
4442
fn current_dir(&self) -> Result<PathBuf, io::Error> {
45-
CurrentDirSource::current_dir(self.deref())
43+
CurrentDirSource::current_dir(self)
4644
}
4745
fn var_os(&self, key: &str) -> Option<OsString> {
48-
VarSource::var_os(self.deref(), key)
46+
VarSource::var_os(self, key)
4947
}
5048
}
5149

src/diskio/test.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ fn test_incremental_file(io_threads: &str) -> Result<()> {
3636
0o666,
3737
io_executor.incremental_file_state(),
3838
)?;
39-
for _ in io_executor.execute(item).collect::<Vec<_>>() {
40-
// The file should be open and incomplete, and no completed chunks
41-
unreachable!();
42-
}
39+
40+
// The file should be open and incomplete, and no completed chunks
41+
assert!(io_executor.execute(item).collect::<Vec<_>>().is_empty());
42+
4343
let mut chunk = io_executor.get_buffer(super::IO_CHUNK_SIZE);
4444
chunk.extend(b"0123456789");
4545
chunk = chunk.finished();
@@ -76,13 +76,12 @@ fn test_incremental_file(io_threads: &str) -> Result<()> {
7676
break;
7777
}
7878
}
79-
assert!(file_finished);
80-
for _ in io_executor.join().collect::<Vec<_>>() {
81-
// no more work should be outstanding
82-
unreachable!();
83-
}
8479

80+
// no more work should be outstanding
81+
assert!(file_finished);
82+
assert!(io_executor.join().collect::<Vec<_>>().is_empty());
8583
assert_eq!(io_executor.buffer_used(), 0);
84+
8685
Ok(())
8786
})?;
8887
// We should be able to read back the file
@@ -143,10 +142,9 @@ fn test_complete_file(io_threads: &str) -> Result<()> {
143142
}
144143
}
145144
assert!(items > 0);
146-
for _ in io_executor.join().collect::<Vec<_>>() {
147-
// no more work should be outstanding
148-
unreachable!();
149-
}
145+
// no more work should be outstanding
146+
assert!(io_executor.join().collect::<Vec<_>>().is_empty());
147+
150148
Ok(())
151149
})?;
152150
// We should be able to read back the file with correct content

tests/suite/cli_v1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ fn bad_sha_on_manifest() {
176176
fn bad_sha_on_installer() {
177177
setup(&|config| {
178178
let dir = config.distdir.as_ref().unwrap().join("dist");
179-
for file in fs::read_dir(&dir).unwrap() {
179+
for file in fs::read_dir(dir).unwrap() {
180180
let file = file.unwrap();
181181
let path = file.path();
182182
let filename = path.to_string_lossy();

tests/suite/cli_v2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ fn bad_sha_on_installer() {
304304
setup(&|config| {
305305
// Since the v2 sha's are contained in the manifest, corrupt the installer
306306
let dir = config.distdir.as_ref().unwrap().join("dist/2015-01-02");
307-
for file in fs::read_dir(&dir).unwrap() {
307+
for file in fs::read_dir(dir).unwrap() {
308308
let file = file.unwrap();
309309
let path = file.path();
310310
let filename = path.to_string_lossy();

0 commit comments

Comments
 (0)