Skip to content

Commit 267cde2

Browse files
committed
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
2 parents 34fd686 + be7b576 commit 267cde2

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/librustc_trans/partitioning.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,17 @@ fn place_root_translation_items<'a, 'tcx, I>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
228228
}
229229
}
230230

231+
// always ensure we have at least one CGU; otherwise, if we have a
232+
// crate with just types (for example), we could wind up with no CGU
233+
if codegen_units.is_empty() {
234+
let codegen_unit_name = InternedString::new(FALLBACK_CODEGEN_UNIT);
235+
codegen_units.entry(codegen_unit_name.clone())
236+
.or_insert_with(|| CodegenUnit {
237+
name: codegen_unit_name.clone(),
238+
items: FnvHashMap(),
239+
});
240+
}
241+
231242
PreInliningPartitioning {
232243
codegen_units: codegen_units.into_iter()
233244
.map(|(_, codegen_unit)| codegen_unit)

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,3 @@ pub type X = u32;
1717
pub type X = i32;
1818

1919
pub type Y = char;
20-
21-
pub fn foo() { }

0 commit comments

Comments
 (0)