about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-05-25 16:53:05 -0700
committerbors <bors@rust-lang.org>2016-05-25 16:53:05 -0700
commit267cde2598db3b858730cc1f700f740964343828 (patch)
treec8acee5977365aba4171999984530a236f9e62d6
parent34fd68668152530dcd1d00865fa8514461b895d7 (diff)
parentbe7b576cc5030e9824ff8f8025dbef9ba92c7fab (diff)
downloadrust-267cde2598db3b858730cc1f700f740964343828.tar.gz
rust-267cde2598db3b858730cc1f700f740964343828.zip
Auto merge of #33732 - nikomatsakis:incr-comp-empty-cgu, r=mw
always make at least one codegen-unit

this allows us to remove the dummy `foo` fn

r? @michaelwoerister
-rw-r--r--src/librustc_trans/partitioning.rs11
-rw-r--r--src/test/incremental/type_alias_cross_crate/auxiliary/a.rs2
2 files changed, 11 insertions, 2 deletions
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() { }