diff --git a/src/librustc_trans/partitioning.rs b/src/librustc_trans/partitioning.rs index 098ba759247..2ded643ef4f 100644 --- a/src/librustc_trans/partitioning.rs +++ b/src/librustc_trans/partitioning.rs @@ -228,6 +228,17 @@ fn place_root_translation_items<'a, 'tcx, I>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } } + // always ensure we have at least one CGU; otherwise, if we have a + // crate with just types (for example), we could wind up with no CGU + if codegen_units.is_empty() { + let codegen_unit_name = InternedString::new(FALLBACK_CODEGEN_UNIT); + codegen_units.entry(codegen_unit_name.clone()) + .or_insert_with(|| CodegenUnit { + name: codegen_unit_name.clone(), + items: FnvHashMap(), + }); + } + PreInliningPartitioning { codegen_units: codegen_units.into_iter() .map(|(_, codegen_unit)| codegen_unit) diff --git a/src/test/incremental/type_alias_cross_crate/auxiliary/a.rs b/src/test/incremental/type_alias_cross_crate/auxiliary/a.rs index 2494dca0509..446d97e5bc0 100644 --- a/src/test/incremental/type_alias_cross_crate/auxiliary/a.rs +++ b/src/test/incremental/type_alias_cross_crate/auxiliary/a.rs @@ -17,5 +17,3 @@ pub type X = u32; pub type X = i32; pub type Y = char; - -pub fn foo() { }