Skip to content

Commit 874d482

Browse files
committed
refactor(fingerprint): move out inner clean_doc
1 parent 95b8e3c commit 874d482

File tree

1 file changed

+25
-24
lines changed

1 file changed

+25
-24
lines changed

src/cargo/core/compiler/fingerprint/rustdoc.rs

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -100,31 +100,32 @@ impl RustDocFingerprint {
100100
.filter(|path| path.exists())
101101
.try_for_each(|path| clean_doc(path))?;
102102
write_fingerprint()?;
103-
return Ok(());
104103

105-
fn clean_doc(path: &Path) -> CargoResult<()> {
106-
let entries = path
107-
.read_dir()
108-
.with_context(|| format!("failed to read directory `{}`", path.display()))?;
109-
for entry in entries {
110-
let entry = entry?;
111-
// Don't remove hidden files. Rustdoc does not create them,
112-
// but the user might have.
113-
if entry
114-
.file_name()
115-
.to_str()
116-
.map_or(false, |name| name.starts_with('.'))
117-
{
118-
continue;
119-
}
120-
let path = entry.path();
121-
if entry.file_type()?.is_dir() {
122-
paths::remove_dir_all(path)?;
123-
} else {
124-
paths::remove_file(path)?;
125-
}
126-
}
127-
Ok(())
104+
Ok(())
105+
}
106+
}
107+
108+
fn clean_doc(path: &Path) -> CargoResult<()> {
109+
let entries = path
110+
.read_dir()
111+
.with_context(|| format!("failed to read directory `{}`", path.display()))?;
112+
for entry in entries {
113+
let entry = entry?;
114+
// Don't remove hidden files. Rustdoc does not create them,
115+
// but the user might have.
116+
if entry
117+
.file_name()
118+
.to_str()
119+
.map_or(false, |name| name.starts_with('.'))
120+
{
121+
continue;
122+
}
123+
let path = entry.path();
124+
if entry.file_type()?.is_dir() {
125+
paths::remove_dir_all(path)?;
126+
} else {
127+
paths::remove_file(path)?;
128128
}
129129
}
130+
Ok(())
130131
}

0 commit comments

Comments
 (0)