From 4afa58511fd7ec3a838f8fe9c49f67b7adfe5edd Mon Sep 17 00:00:00 2001 From: CPerezz Date: Thu, 4 Feb 2021 01:03:04 +0100 Subject: [PATCH] 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. --- src/cargo/core/compiler/build_context/target_info.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/cargo/core/compiler/build_context/target_info.rs b/src/cargo/core/compiler/build_context/target_info.rs index dd052e72204..8dc3b516f35 100644 --- a/src/cargo/core/compiler/build_context/target_info.rs +++ b/src/cargo/core/compiler/build_context/target_info.rs @@ -774,16 +774,13 @@ impl RustDocFingerprint { } fn remove_doc_dirs(doc_dirs: &Vec<&Path>) -> CargoResult<()> { - let errs: Vec> = doc_dirs + doc_dirs .iter() + .filter(|path| path.exists()) .map(|path| paths::remove_dir_all(&path)) .filter(|res| res.is_err()) - .collect(); - if !errs.is_empty() { - Err(anyhow::anyhow!("Dir removal error")) - } else { - Ok(()) - } + .collect::>>() + .map(|_| ()) } /// This function checks whether the latest version of `Rustc` used to compile this