about summary refs log tree commit diff
path: root/compiler/rustc_incremental/src
diff options
context:
space:
mode:
authorbjorn3 <bjorn3@users.noreply.github.com>2022-05-15 11:31:28 +0000
committerbjorn3 <bjorn3@users.noreply.github.com>2022-06-06 12:39:32 +0000
commite16c3b4a44214add436e9834d2090a7288eba3a3 (patch)
tree0a54779a2757f511fbcbf5bc9d160aa4c9e978d4 /compiler/rustc_incremental/src
parent906b85157cc7928d86fd186a255f3fd89543aca8 (diff)
downloadrust-e16c3b4a44214add436e9834d2090a7288eba3a3.tar.gz
rust-e16c3b4a44214add436e9834d2090a7288eba3a3.zip
Make saved_file field of WorkProduct non-optional
A WorkProduct without a saved file is useless
Diffstat (limited to 'compiler/rustc_incremental/src')
-rw-r--r--compiler/rustc_incremental/src/persist/load.rs20
-rw-r--r--compiler/rustc_incremental/src/persist/save.rs9
-rw-r--r--compiler/rustc_incremental/src/persist/work_product.rs22
3 files changed, 21 insertions, 30 deletions
diff --git a/compiler/rustc_incremental/src/persist/load.rs b/compiler/rustc_incremental/src/persist/load.rs
index 908a9361424..9de14950aa8 100644
--- a/compiler/rustc_incremental/src/persist/load.rs
+++ b/compiler/rustc_incremental/src/persist/load.rs
@@ -162,18 +162,16 @@ pub fn load_dep_graph(sess: &Session) -> DepGraphFuture {
 
             for swp in work_products {
                 let mut all_files_exist = true;
-                if let Some(ref file_name) = swp.work_product.saved_file {
-                    let path = in_incr_comp_dir_sess(sess, file_name);
-                    if !path.exists() {
-                        all_files_exist = false;
-
-                        if sess.opts.debugging_opts.incremental_info {
-                            eprintln!(
-                                "incremental: could not find file for work \
+                let path = in_incr_comp_dir_sess(sess, &swp.work_product.saved_file);
+                if !path.exists() {
+                    all_files_exist = false;
+
+                    if sess.opts.debugging_opts.incremental_info {
+                        eprintln!(
+                            "incremental: could not find file for work \
                                     product: {}",
-                                path.display()
-                            );
-                        }
+                            path.display()
+                        );
                     }
                 }
 
diff --git a/compiler/rustc_incremental/src/persist/save.rs b/compiler/rustc_incremental/src/persist/save.rs
index 20ffde90064..0223976b08a 100644
--- a/compiler/rustc_incremental/src/persist/save.rs
+++ b/compiler/rustc_incremental/src/persist/save.rs
@@ -107,11 +107,7 @@ pub fn save_work_product_index(
     for (id, wp) in previous_work_products.iter() {
         if !new_work_products.contains_key(id) {
             work_product::delete_workproduct_files(sess, wp);
-            debug_assert!(
-                wp.saved_file.as_ref().map_or(true, |file_name| {
-                    !in_incr_comp_dir_sess(sess, &file_name).exists()
-                })
-            );
+            debug_assert!(!in_incr_comp_dir_sess(sess, &wp.saved_file).exists());
         }
     }
 
@@ -119,8 +115,7 @@ pub fn save_work_product_index(
     debug_assert!({
         new_work_products
             .iter()
-            .flat_map(|(_, wp)| wp.saved_file.iter())
-            .map(|name| in_incr_comp_dir_sess(sess, name))
+            .map(|(_, wp)| in_incr_comp_dir_sess(sess, &wp.saved_file))
             .all(|path| path.exists())
     });
 }
diff --git a/compiler/rustc_incremental/src/persist/work_product.rs b/compiler/rustc_incremental/src/persist/work_product.rs
index 2d5cbc28d6e..4789c0f581f 100644
--- a/compiler/rustc_incremental/src/persist/work_product.rs
+++ b/compiler/rustc_incremental/src/persist/work_product.rs
@@ -21,7 +21,7 @@ pub fn copy_cgu_workproduct_to_incr_comp_cache_dir(
     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),
+        Ok(_) => file_name,
         Err(err) => {
             sess.warn(&format!(
                 "error copying object file `{}` to incremental directory as `{}`: {}",
@@ -41,17 +41,15 @@ pub fn copy_cgu_workproduct_to_incr_comp_cache_dir(
 
 /// Removes files for a given work product.
 pub fn delete_workproduct_files(sess: &Session, work_product: &WorkProduct) {
-    if let Some(ref file_name) = work_product.saved_file {
-        let path = in_incr_comp_dir_sess(sess, file_name);
-        match std_fs::remove_file(&path) {
-            Ok(()) => {}
-            Err(err) => {
-                sess.warn(&format!(
-                    "file-system error deleting outdated file `{}`: {}",
-                    path.display(),
-                    err
-                ));
-            }
+    let path = in_incr_comp_dir_sess(sess, &work_product.saved_file);
+    match std_fs::remove_file(&path) {
+        Ok(()) => {}
+        Err(err) => {
+            sess.warn(&format!(
+                "file-system error deleting outdated file `{}`: {}",
+                path.display(),
+                err
+            ));
         }
     }
 }