Skip to content

Commit

Permalink
fix clippy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
syphar committed Apr 17, 2024
1 parent fcc85e1 commit 96abe08
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/cmd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ impl<'w, 'pl> Command<'w, 'pl> {
}
};

let mut cmd = AsyncCommand::new(&binary);
let mut cmd = AsyncCommand::new(binary);
cmd.args(&self.args);

if managed_by_rustwide {
Expand Down
2 changes: 1 addition & 1 deletion src/crates/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl GitRepo {

match res {
Ok(out) => {
if let Some(shaline) = out.stdout_lines().get(0) {
if let Some(shaline) = out.stdout_lines().first() {
if !shaline.is_empty() {
return Some(shaline.to_string());
}
Expand Down
2 changes: 1 addition & 1 deletion src/toolchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ pub(crate) fn list_installed_toolchains(rustup_home: &Path) -> Result<Vec<Toolch
let update_hashes = rustup_home.join("update-hashes");

let mut result = Vec::new();
for entry in std::fs::read_dir(&rustup_home.join("toolchains"))? {
for entry in std::fs::read_dir(rustup_home.join("toolchains"))? {
let entry = entry?;
let name = entry
.file_name()
Expand Down
41 changes: 21 additions & 20 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub(crate) fn file_lock<T>(
.read(true)
.write(true)
.create(true)
.truncate(true)
.open(path)?;

let mut message_displayed = false;
Expand Down Expand Up @@ -108,26 +109,6 @@ fn improve_remove_error(error: std::io::Error, path: &Path) -> std::io::Error {
)
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn custom_remove_error() {
let path = "test/path".as_ref();

let expected = "failed to remove 'test/path' : Kind(PermissionDenied)";
let tested = format!(
"{}",
improve_remove_error(
std::io::Error::from(std::io::ErrorKind::PermissionDenied),
path
)
);
assert_eq!(expected, tested);
}
}

pub(crate) fn normalize_path(path: &Path) -> PathBuf {
let mut p = std::fs::canonicalize(path).unwrap_or_else(|_| path.to_path_buf());

Expand Down Expand Up @@ -163,6 +144,26 @@ pub(crate) fn normalize_path(path: &Path) -> PathBuf {
p
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn custom_remove_error() {
let path = "test/path".as_ref();

let expected = "failed to remove 'test/path' : Kind(PermissionDenied)";
let tested = format!(
"{}",
improve_remove_error(
std::io::Error::from(std::io::ErrorKind::PermissionDenied),
path
)
);
assert_eq!(expected, tested);
}
}

#[cfg(test)]
#[cfg(windows)]
mod windows_tests {
Expand Down
2 changes: 1 addition & 1 deletion tests/buildtest/inside_docker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn execute(test: &str) -> Result<(), Error> {
let target_prefix = Path::new(TARGET_PREFIX);
let container_exe = target_prefix.join(
current_exe
.strip_prefix(&target_parent_dir)
.strip_prefix(target_parent_dir)
.with_context(|_| "could not determine cargo target dir")?,
);
let src_mount = os_string!(&current_dir, ":", &container_prefix);
Expand Down

0 comments on commit 96abe08

Please sign in to comment.