]> git.lizzy.rs Git - rust.git/commitdiff
always make at least one codegen-unit
authorNiko Matsakis <niko@alum.mit.edu>
Thu, 19 May 2016 00:19:07 +0000 (20:19 -0400)
committerNiko Matsakis <niko@alum.mit.edu>
Thu, 19 May 2016 01:24:30 +0000 (21:24 -0400)
this allows us to remove the dummy `foo` fn

src/librustc_trans/partitioning.rs
src/test/incremental/type_alias_cross_crate/auxiliary/a.rs

index 098ba759247be44d8a4b128cc290921f7e067994..d2ddbccee8b424494ea70078a1f5018958fdac7e 100644 (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)
index 2494dca0509b16ea79923b3681388b21e0422adb..446d97e5bc0548bb995d3153842148bdf54c27dd 100644 (file)
@@ -17,5 +17,3 @@
 pub type X = i32;
 
 pub type Y = char;
-
-pub fn foo() { }