about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2016-05-18 20:19:07 -0400
committerNiko Matsakis <niko@alum.mit.edu>2016-05-18 21:24:30 -0400
commit02af34def742cf1e1ad0427e1a1760114ceefdc7 (patch)
tree4b0ca5986cfa6c7c608d2e5fcf0b521d5ec96a27
parent9a140454ea47b7fd107b6e963b7ea2aef74e9518 (diff)
downloadrust-02af34def742cf1e1ad0427e1a1760114ceefdc7.tar.gz
rust-02af34def742cf1e1ad0427e1a1760114ceefdc7.zip
always make at least one codegen-unit
this allows us to remove the dummy `foo` fn
-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..d2ddbccee8b 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 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)
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() { }