Skip to content

Commit f7ccfc6

Browse files
committed
Review feedbacK: conservatively respond to file missing and IO errors.
1 parent 7f485fb commit f7ccfc6

File tree

1 file changed

+7
-8
lines changed
  • src/librustc_codegen_llvm/back

1 file changed

+7
-8
lines changed

src/librustc_codegen_llvm/back/lto.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -483,11 +483,11 @@ fn thin_lto(cgcx: &CodegenContext<LlvmCodegenBackend>,
483483
if let Some(ref incr_comp_session_dir) = cgcx.incr_comp_session_dir
484484
{
485485
let path = incr_comp_session_dir.join(THIN_LTO_IMPORTS_INCR_COMP_FILE_NAME);
486+
// If previous imports have been deleted, or we get an IO error
487+
// reading the file storing them, then we'll just use `None` as the
488+
// prev_import_map, which will force the code to be recompiled.
486489
let prev = if path.exists() {
487-
// FIXME: can/should we recover from IO error occuring here
488-
// (e.g. by clearing green_modules), rather than panicking from
489-
// unwrap call?
490-
Some(ThinLTOImports::load_from_file(&path).unwrap())
490+
ThinLTOImports::load_from_file(&path).ok()
491491
} else {
492492
None
493493
};
@@ -536,11 +536,10 @@ fn thin_lto(cgcx: &CodegenContext<LlvmCodegenBackend>,
536536
// are doing the ThinLTO in this current compilation cycle.)
537537
//
538538
// See rust-lang/rust#59535.
539-
if green_modules.contains_key(module_name) {
539+
if let (Some(prev_import_map), true) =
540+
(prev_import_map.as_ref(), green_modules.contains_key(module_name))
541+
{
540542
assert!(cgcx.incr_comp_session_dir.is_some());
541-
assert!(prev_import_map.is_some());
542-
543-
let prev_import_map = prev_import_map.as_ref().unwrap();
544543

545544
let prev_imports = prev_import_map.modules_imported_by(module_name);
546545
let curr_imports = curr_import_map.modules_imported_by(module_name);

0 commit comments

Comments
 (0)