Skip to content

Commit

Permalink
Improve RustDocFingerprint::remove_doc_dirs
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
CPerezz committed Feb 4, 2021
1 parent e78f91c commit 4afa585
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/cargo/core/compiler/build_context/target_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -774,16 +774,13 @@ impl RustDocFingerprint {
}

fn remove_doc_dirs(doc_dirs: &Vec<&Path>) -> CargoResult<()> {
let errs: Vec<CargoResult<()>> = 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::<CargoResult<Vec<()>>>()
.map(|_| ())
}

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

0 comments on commit 4afa585

Please sign in to comment.