Skip to content

Commit

Permalink
Apply clippy suggestions from Rust 1.74
Browse files Browse the repository at this point in the history
  • Loading branch information
djc committed Oct 4, 2023
1 parent d4c6844 commit e1b2b9a
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 24 deletions.
6 changes: 3 additions & 3 deletions src/cli/rustup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ pub(crate) fn cli() -> Command {
.subcommand(
Command::new("update")
.about("Update Rust toolchains and rustup")
.aliases(&["upgrade", "up"])
.aliases(["upgrade", "up"])
.after_help(UPDATE_HELP)
.arg(
Arg::new("toolchain")
Expand Down Expand Up @@ -413,7 +413,7 @@ pub(crate) fn cli() -> Command {
.subcommand(
Command::new("install")
.about("Install or update a given toolchain")
.aliases(&["update", "add"])
.aliases(["update", "add"])
.arg(
Arg::new("toolchain")
.help(OFFICIAL_TOOLCHAIN_ARG_HELP)
Expand Down Expand Up @@ -727,7 +727,7 @@ pub(crate) fn cli() -> Command {
.arg(Arg::new("topic").help(TOPIC_ARG_HELP))
.group(
ArgGroup::new("page").args(
&DOCS_DATA
DOCS_DATA
.iter()
.map(|(name, _, _)| *name)
.collect::<Vec<_>>(),
Expand Down
4 changes: 2 additions & 2 deletions src/cli/self_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ fn install_bins() -> Result<()> {

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

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

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

let cargo_home = utils::cargo_home()?;

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

Expand Down
6 changes: 2 additions & 4 deletions src/currentprocess/homethunk.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/// Adapts currentprocess to the trait home::Env
use std::ffi::OsString;
use std::io;
#[cfg(feature = "test")]
use std::ops::Deref;
use std::path::PathBuf;

use home::env as home;
Expand Down Expand Up @@ -42,10 +40,10 @@ impl home::Env for TestProcess {
self.var("HOME").ok().map(|v| v.into())
}
fn current_dir(&self) -> Result<PathBuf, io::Error> {
CurrentDirSource::current_dir(self.deref())
CurrentDirSource::current_dir(self)
}
fn var_os(&self, key: &str) -> Option<OsString> {
VarSource::var_os(self.deref(), key)
VarSource::var_os(self, key)
}
}

Expand Down
24 changes: 11 additions & 13 deletions src/diskio/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ fn test_incremental_file(io_threads: &str) -> Result<()> {
0o666,
io_executor.incremental_file_state(),
)?;
for _ in io_executor.execute(item).collect::<Vec<_>>() {
// The file should be open and incomplete, and no completed chunks
unreachable!();
}

// The file should be open and incomplete, and no completed chunks
assert!(io_executor.execute(item).collect::<Vec<_>>().is_empty());

let mut chunk = io_executor.get_buffer(super::IO_CHUNK_SIZE);
chunk.extend(b"0123456789");
chunk = chunk.finished();
Expand Down Expand Up @@ -76,13 +76,12 @@ fn test_incremental_file(io_threads: &str) -> Result<()> {
break;
}
}
assert!(file_finished);
for _ in io_executor.join().collect::<Vec<_>>() {
// no more work should be outstanding
unreachable!();
}

// no more work should be outstanding
assert!(file_finished);
assert!(io_executor.join().collect::<Vec<_>>().is_empty());
assert_eq!(io_executor.buffer_used(), 0);

Ok(())
})?;
// We should be able to read back the file
Expand Down Expand Up @@ -143,10 +142,9 @@ fn test_complete_file(io_threads: &str) -> Result<()> {
}
}
assert!(items > 0);
for _ in io_executor.join().collect::<Vec<_>>() {
// no more work should be outstanding
unreachable!();
}
// no more work should be outstanding
assert!(io_executor.join().collect::<Vec<_>>().is_empty());

Ok(())
})?;
// We should be able to read back the file with correct content
Expand Down
2 changes: 1 addition & 1 deletion tests/suite/cli_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ fn bad_sha_on_manifest() {
fn bad_sha_on_installer() {
setup(&|config| {
let dir = config.distdir.as_ref().unwrap().join("dist");
for file in fs::read_dir(&dir).unwrap() {
for file in fs::read_dir(dir).unwrap() {
let file = file.unwrap();
let path = file.path();
let filename = path.to_string_lossy();
Expand Down
2 changes: 1 addition & 1 deletion tests/suite/cli_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ fn bad_sha_on_installer() {
setup(&|config| {
// Since the v2 sha's are contained in the manifest, corrupt the installer
let dir = config.distdir.as_ref().unwrap().join("dist/2015-01-02");
for file in fs::read_dir(&dir).unwrap() {
for file in fs::read_dir(dir).unwrap() {
let file = file.unwrap();
let path = file.path();
let filename = path.to_string_lossy();
Expand Down

0 comments on commit e1b2b9a

Please sign in to comment.