Skip to content

Commit 3d8e854

Browse files
committed
Make saved_file field of WorkProduct non-optional
A WorkProduct without a saved file is useless
1 parent bbb8509 commit 3d8e854

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

src/driver/aot.rs

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -80,29 +80,24 @@ fn reuse_workproduct_for_cgu(
8080
cgu: &CodegenUnit<'_>,
8181
work_products: &mut FxHashMap<WorkProductId, WorkProduct>,
8282
) -> CompiledModule {
83-
let mut object = None;
8483
let work_product = cgu.previous_work_product(tcx);
85-
if let Some(saved_file) = &work_product.saved_file {
86-
let obj_out =
87-
tcx.output_filenames(()).temp_path(OutputType::Object, Some(cgu.name().as_str()));
88-
object = Some(obj_out.clone());
89-
let source_file = rustc_incremental::in_incr_comp_dir_sess(&tcx.sess, &saved_file);
90-
if let Err(err) = rustc_fs_util::link_or_copy(&source_file, &obj_out) {
91-
tcx.sess.err(&format!(
92-
"unable to copy {} to {}: {}",
93-
source_file.display(),
94-
obj_out.display(),
95-
err
96-
));
97-
}
84+
let obj_out = tcx.output_filenames(()).temp_path(OutputType::Object, Some(cgu.name().as_str()));
85+
let source_file = rustc_incremental::in_incr_comp_dir_sess(&tcx.sess, &work_product.saved_file);
86+
if let Err(err) = rustc_fs_util::link_or_copy(&source_file, &obj_out) {
87+
tcx.sess.err(&format!(
88+
"unable to copy {} to {}: {}",
89+
source_file.display(),
90+
obj_out.display(),
91+
err
92+
));
9893
}
9994

10095
work_products.insert(cgu.work_product_id(), work_product);
10196

10297
CompiledModule {
10398
name: cgu.name().to_string(),
10499
kind: ModuleKind::Regular,
105-
object,
100+
object: Some(obj_out),
106101
dwarf_object: None,
107102
bytecode: None,
108103
}

0 commit comments

Comments
 (0)