Skip to content

Commit 2da7a5d

Browse files
committed
fix clippy errors
1 parent fcc85e1 commit 2da7a5d

File tree

5 files changed

+25
-24
lines changed

5 files changed

+25
-24
lines changed

src/cmd/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ impl<'w, 'pl> Command<'w, 'pl> {
439439
}
440440
};
441441

442-
let mut cmd = AsyncCommand::new(&binary);
442+
let mut cmd = AsyncCommand::new(binary);
443443
cmd.args(&self.args);
444444

445445
if managed_by_rustwide {

src/crates/git.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ impl GitRepo {
2323

2424
match res {
2525
Ok(out) => {
26-
if let Some(shaline) = out.stdout_lines().get(0) {
26+
if let Some(shaline) = out.stdout_lines().first() {
2727
if !shaline.is_empty() {
2828
return Some(shaline.to_string());
2929
}

src/toolchain.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ pub(crate) fn list_installed_toolchains(rustup_home: &Path) -> Result<Vec<Toolch
526526
let update_hashes = rustup_home.join("update-hashes");
527527

528528
let mut result = Vec::new();
529-
for entry in std::fs::read_dir(&rustup_home.join("toolchains"))? {
529+
for entry in std::fs::read_dir(rustup_home.join("toolchains"))? {
530530
let entry = entry?;
531531
let name = entry
532532
.file_name()

src/utils.rs

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ pub(crate) fn file_lock<T>(
3030
.read(true)
3131
.write(true)
3232
.create(true)
33+
.truncate(true)
3334
.open(path)?;
3435

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

111-
#[cfg(test)]
112-
mod tests {
113-
use super::*;
114-
115-
#[test]
116-
fn custom_remove_error() {
117-
let path = "test/path".as_ref();
118-
119-
let expected = "failed to remove 'test/path' : Kind(PermissionDenied)";
120-
let tested = format!(
121-
"{}",
122-
improve_remove_error(
123-
std::io::Error::from(std::io::ErrorKind::PermissionDenied),
124-
path
125-
)
126-
);
127-
assert_eq!(expected, tested);
128-
}
129-
}
130-
131112
pub(crate) fn normalize_path(path: &Path) -> PathBuf {
132113
let mut p = std::fs::canonicalize(path).unwrap_or_else(|_| path.to_path_buf());
133114

@@ -163,6 +144,26 @@ pub(crate) fn normalize_path(path: &Path) -> PathBuf {
163144
p
164145
}
165146

147+
#[cfg(test)]
148+
mod tests {
149+
use super::*;
150+
151+
#[test]
152+
fn custom_remove_error() {
153+
let path = "test/path".as_ref();
154+
155+
let expected = "failed to remove 'test/path' : Kind(PermissionDenied)";
156+
let tested = format!(
157+
"{}",
158+
improve_remove_error(
159+
std::io::Error::from(std::io::ErrorKind::PermissionDenied),
160+
path
161+
)
162+
);
163+
assert_eq!(expected, tested);
164+
}
165+
}
166+
166167
#[cfg(test)]
167168
#[cfg(windows)]
168169
mod windows_tests {

tests/buildtest/inside_docker.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fn execute(test: &str) -> Result<(), Error> {
3636
let target_prefix = Path::new(TARGET_PREFIX);
3737
let container_exe = target_prefix.join(
3838
current_exe
39-
.strip_prefix(&target_parent_dir)
39+
.strip_prefix(target_parent_dir)
4040
.with_context(|_| "could not determine cargo target dir")?,
4141
);
4242
let src_mount = os_string!(&current_dir, ":", &container_prefix);

0 commit comments

Comments
 (0)