Skip to content

Commit 4afa585

Browse files
committed
Improve RustDocFingerprint::remove_doc_dirs
We were not filtering the cases where the doc folder paths did not exist. Also, we were overrwriting the error when it doesn't make sense. We now return the first one by folding the results of the doc_dirs removal resolutions.
1 parent e78f91c commit 4afa585

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/cargo/core/compiler/build_context/target_info.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -774,16 +774,13 @@ impl RustDocFingerprint {
774774
}
775775

776776
fn remove_doc_dirs(doc_dirs: &Vec<&Path>) -> CargoResult<()> {
777-
let errs: Vec<CargoResult<()>> = doc_dirs
777+
doc_dirs
778778
.iter()
779+
.filter(|path| path.exists())
779780
.map(|path| paths::remove_dir_all(&path))
780781
.filter(|res| res.is_err())
781-
.collect();
782-
if !errs.is_empty() {
783-
Err(anyhow::anyhow!("Dir removal error"))
784-
} else {
785-
Ok(())
786-
}
782+
.collect::<CargoResult<Vec<()>>>()
783+
.map(|_| ())
787784
}
788785

789786
/// This function checks whether the latest version of `Rustc` used to compile this

0 commit comments

Comments
 (0)