Skip to content

Commit 7f7fdaa

Browse files
committed
fix formatting
1 parent 26c7bd7 commit 7f7fdaa

File tree

5 files changed

+39
-12
lines changed

5 files changed

+39
-12
lines changed

src/build.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ impl BuildDirectory {
146146
) -> Result<R, Error> {
147147
let source_dir = self.source_dir();
148148
if source_dir.exists() {
149-
remove_dir_all(&source_dir).map_err(|error|crate::utils::improve_remove_dir_error(error, &source_dir))?;
149+
remove_dir_all(&source_dir)
150+
.map_err(|error| crate::utils::improve_remove_dir_error(error, &source_dir))?;
150151
}
151152

152153
let mut prepare = Prepare::new(&self.workspace, toolchain, krate, &source_dir, patches);
@@ -159,15 +160,17 @@ impl BuildDirectory {
159160
sandbox,
160161
})?;
161162

162-
remove_dir_all(&source_dir).map_err(|error|crate::utils::improve_remove_dir_error(error, &source_dir))?;
163+
remove_dir_all(&source_dir)
164+
.map_err(|error| crate::utils::improve_remove_dir_error(error, &source_dir))?;
163165
Ok(res)
164166
}
165167

166168
/// Remove all the contents of the build directory, freeing disk space.
167169
pub fn purge(&mut self) -> Result<(), Error> {
168170
let build_dir = self.build_dir();
169171
if build_dir.exists() {
170-
remove_dir_all(&build_dir).map_err(|error|crate::utils::improve_remove_dir_error(error, &build_dir))?;
172+
remove_dir_all(&build_dir)
173+
.map_err(|error| crate::utils::improve_remove_dir_error(error, &build_dir))?;
171174
}
172175
Ok(())
173176
}

src/crates/git.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ impl CrateTrait for GitRepo {
121121
fn purge_from_cache(&self, workspace: &Workspace) -> Result<(), Error> {
122122
let path = self.cached_path(workspace);
123123
if path.exists() {
124-
remove_dir_all::remove_dir_all(&path).map_err(|error|crate::utils::improve_remove_dir_error(error, &path))?;
124+
remove_dir_all::remove_dir_all(&path)
125+
.map_err(|error| crate::utils::improve_remove_dir_error(error, &path))?;
125126
}
126127
Ok(())
127128
}

src/crates/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ impl Crate {
6969
"crate source directory {} already exists, cleaning it up",
7070
dest.display()
7171
);
72-
remove_dir_all(dest).map_err(|error|crate::utils::improve_remove_dir_error(error, dest))?;
72+
remove_dir_all(dest)
73+
.map_err(|error| crate::utils::improve_remove_dir_error(error, dest))?;
7374
}
7475
self.as_trait().copy_source_to(workspace, dest)
7576
}

src/utils.rs

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,25 +60,45 @@ impl std::error::Error for DirRemoveError {}
6060

6161
impl std::fmt::Display for DirRemoveError {
6262
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
63-
f.write_fmt(format_args!("failed to remove directory '{}' : {:?}",self.path, self.kind))
63+
f.write_fmt(format_args!(
64+
"failed to remove directory '{}' : {:?}",
65+
self.path, self.kind
66+
))
6467
}
6568
}
6669

6770
pub(crate) fn improve_remove_dir_error(error: std::io::Error, path: &Path) -> std::io::Error {
68-
std::io::Error::new(error.kind(), DirRemoveError{kind: error.kind(),path: path.display().to_string()})
71+
std::io::Error::new(
72+
error.kind(),
73+
DirRemoveError {
74+
kind: error.kind(),
75+
path: path.display().to_string(),
76+
},
77+
)
6978
}
7079

7180
#[test]
7281
fn custom_remove_dir_error() {
73-
7482
let path = "test/path".as_ref();
7583

7684
let expected = "failed to remove directory 'test/path' : PermissionDenied";
77-
let tested = format!("{}", improve_remove_dir_error(std::io::Error::from(std::io::ErrorKind::PermissionDenied), path));
85+
let tested = format!(
86+
"{}",
87+
improve_remove_dir_error(
88+
std::io::Error::from(std::io::ErrorKind::PermissionDenied),
89+
path
90+
)
91+
);
7892
assert_eq!(expected, tested);
7993

8094
let expected = "Custom { kind: PermissionDenied, error: DirRemoveError { kind: PermissionDenied, path: \"test/path\" } }";
81-
let tested = format!("{:?}",improve_remove_dir_error(std::io::Error::from(std::io::ErrorKind::PermissionDenied), path));
95+
let tested = format!(
96+
"{:?}",
97+
improve_remove_dir_error(
98+
std::io::Error::from(std::io::ErrorKind::PermissionDenied),
99+
path
100+
)
101+
);
82102
assert_eq!(expected, tested);
83103
}
84104

src/workspace.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ impl Workspace {
213213
pub fn purge_all_build_dirs(&self) -> Result<(), Error> {
214214
let dir = self.builds_dir();
215215
if dir.exists() {
216-
remove_dir_all(&dir).map_err(|error|crate::utils::improve_remove_dir_error(error, &dir))?;
216+
remove_dir_all(&dir)
217+
.map_err(|error| crate::utils::improve_remove_dir_error(error, &dir))?;
217218
}
218219
Ok(())
219220
}
@@ -236,7 +237,8 @@ impl Workspace {
236237

237238
for path in &paths {
238239
if path.exists() {
239-
remove_dir_all(&path).map_err(|error|crate::utils::improve_remove_dir_error(error, &path))?;
240+
remove_dir_all(&path)
241+
.map_err(|error| crate::utils::improve_remove_dir_error(error, &path))?;
240242
}
241243
}
242244

0 commit comments

Comments
 (0)