Skip to content

Commit

Permalink
Make saved_file field of WorkProduct non-optional
Browse files Browse the repository at this point in the history
A WorkProduct without a saved file is useless
  • Loading branch information
bjorn3 committed Jun 6, 2022
1 parent bbb8509 commit 3d8e854
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions src/driver/aot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,29 +80,24 @@ fn reuse_workproduct_for_cgu(
cgu: &CodegenUnit<'_>,
work_products: &mut FxHashMap<WorkProductId, WorkProduct>,
) -> CompiledModule {
let mut object = None;
let work_product = cgu.previous_work_product(tcx);
if let Some(saved_file) = &work_product.saved_file {
let obj_out =
tcx.output_filenames(()).temp_path(OutputType::Object, Some(cgu.name().as_str()));
object = Some(obj_out.clone());
let source_file = rustc_incremental::in_incr_comp_dir_sess(&tcx.sess, &saved_file);
if let Err(err) = rustc_fs_util::link_or_copy(&source_file, &obj_out) {
tcx.sess.err(&format!(
"unable to copy {} to {}: {}",
source_file.display(),
obj_out.display(),
err
));
}
let obj_out = tcx.output_filenames(()).temp_path(OutputType::Object, Some(cgu.name().as_str()));
let source_file = rustc_incremental::in_incr_comp_dir_sess(&tcx.sess, &work_product.saved_file);
if let Err(err) = rustc_fs_util::link_or_copy(&source_file, &obj_out) {
tcx.sess.err(&format!(
"unable to copy {} to {}: {}",
source_file.display(),
obj_out.display(),
err
));
}

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

CompiledModule {
name: cgu.name().to_string(),
kind: ModuleKind::Regular,
object,
object: Some(obj_out),
dwarf_object: None,
bytecode: None,
}
Expand Down

0 comments on commit 3d8e854

Please sign in to comment.