From 02af34def742cf1e1ad0427e1a1760114ceefdc7 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Wed, 18 May 2016 20:19:07 -0400 Subject: [PATCH 1/2] always make at least one codegen-unit this allows us to remove the dummy `foo` fn --- src/librustc_trans/partitioning.rs | 11 +++++++++++ .../incremental/type_alias_cross_crate/auxiliary/a.rs | 2 -- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/librustc_trans/partitioning.rs b/src/librustc_trans/partitioning.rs index 098ba759247be..d2ddbccee8b42 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 2494dca0509b1..446d97e5bc054 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() { } From be7b576cc5030e9824ff8f8025dbef9ba92c7fab Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Tue, 24 May 2016 15:08:07 -0400 Subject: [PATCH 2/2] correct typo in comment --- src/librustc_trans/partitioning.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_trans/partitioning.rs b/src/librustc_trans/partitioning.rs index d2ddbccee8b42..2ded643ef4fdd 100644 --- a/src/librustc_trans/partitioning.rs +++ b/src/librustc_trans/partitioning.rs @@ -228,7 +228,7 @@ 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 + // 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);