always make at least one codegen-unit

this allows us to remove the dummy `foo` fn
This commit is contained in:
Niko Matsakis 2016-05-18 20:19:07 -04:00
parent 9a140454ea
commit 02af34def7
2 changed files with 11 additions and 2 deletions

View file

@ -228,6 +228,17 @@ fn place_root_translation_items<'a, 'tcx, I>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
}
}
// always ensure we have at least one CGO; 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)

View file

@ -17,5 +17,3 @@ pub type X = u32;
pub type X = i32;
pub type Y = char;
pub fn foo() { }