@@ -483,11 +483,11 @@ fn thin_lto(cgcx: &CodegenContext<LlvmCodegenBackend>,
483
483
if let Some ( ref incr_comp_session_dir) = cgcx. incr_comp_session_dir
484
484
{
485
485
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.
486
489
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 ( )
491
491
} else {
492
492
None
493
493
} ;
@@ -536,11 +536,10 @@ fn thin_lto(cgcx: &CodegenContext<LlvmCodegenBackend>,
536
536
// are doing the ThinLTO in this current compilation cycle.)
537
537
//
538
538
// 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
+ {
540
542
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 ( ) ;
544
543
545
544
let prev_imports = prev_import_map. modules_imported_by ( module_name) ;
546
545
let curr_imports = curr_import_map. modules_imported_by ( module_name) ;
0 commit comments