diff options
| author | bjorn3 <bjorn3@users.noreply.github.com> | 2022-05-13 12:20:32 +0000 |
|---|---|---|
| committer | bjorn3 <bjorn3@users.noreply.github.com> | 2022-06-06 12:38:38 +0000 |
| commit | 906b85157cc7928d86fd186a255f3fd89543aca8 (patch) | |
| tree | 1fb4112c7cca2c3dd0cb9db943ae57c8f95b0bb3 /compiler/rustc_incremental/src | |
| parent | 065e202b563b7f690b7cc79b8fb5a61150c2976e (diff) | |
| download | rust-906b85157cc7928d86fd186a255f3fd89543aca8.tar.gz rust-906b85157cc7928d86fd186a255f3fd89543aca8.zip | |
Factor Option out of copy_cgu_workproduct_to_incr_comp_cache_dir call
This improves clarity of the code a bit
Diffstat (limited to 'compiler/rustc_incremental/src')
| -rw-r--r-- | compiler/rustc_incremental/src/persist/work_product.rs | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/compiler/rustc_incremental/src/persist/work_product.rs b/compiler/rustc_incremental/src/persist/work_product.rs index 54b06e56d24..2d5cbc28d6e 100644 --- a/compiler/rustc_incremental/src/persist/work_product.rs +++ b/compiler/rustc_incremental/src/persist/work_product.rs @@ -13,28 +13,24 @@ use std::path::Path; pub fn copy_cgu_workproduct_to_incr_comp_cache_dir( sess: &Session, cgu_name: &str, - path: Option<&Path>, + path: &Path, ) -> Option<(WorkProductId, WorkProduct)> { debug!("copy_cgu_workproduct_to_incr_comp_cache_dir({:?},{:?})", cgu_name, path); sess.opts.incremental.as_ref()?; - let saved_file = if let Some(path) = path { - let file_name = format!("{}.o", cgu_name); - let path_in_incr_dir = in_incr_comp_dir_sess(sess, &file_name); - match link_or_copy(path, &path_in_incr_dir) { - Ok(_) => Some(file_name), - Err(err) => { - sess.warn(&format!( - "error copying object file `{}` to incremental directory as `{}`: {}", - path.display(), - path_in_incr_dir.display(), - err - )); - return None; - } + let file_name = format!("{}.o", cgu_name); + let path_in_incr_dir = in_incr_comp_dir_sess(sess, &file_name); + let saved_file = match link_or_copy(path, &path_in_incr_dir) { + Ok(_) => Some(file_name), + Err(err) => { + sess.warn(&format!( + "error copying object file `{}` to incremental directory as `{}`: {}", + path.display(), + path_in_incr_dir.display(), + err + )); + return None; } - } else { - None }; let work_product = WorkProduct { cgu_name: cgu_name.to_string(), saved_file }; |
