diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 2f4c03f0953d3..b13e33718b299 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -1929,13 +1929,17 @@ impl<'tcx> TyCtxt<'tcx> { if arg_cor_ty.is_coroutine() { let span = self.def_span(def_id); let source_info = SourceInfo::outermost(span); + // Even minimal, empty coroutine has 3 states (RESERVED_VARIANTS), + // so variant_fields and variant_source_info should have 3 elements. let variant_fields: IndexVec> = iter::repeat(IndexVec::new()).take(CoroutineArgs::RESERVED_VARIANTS).collect(); + let variant_source_info: IndexVec = + iter::repeat(source_info).take(CoroutineArgs::RESERVED_VARIANTS).collect(); let proxy_layout = CoroutineLayout { field_tys: [].into(), field_names: [].into(), variant_fields, - variant_source_info: [source_info].into(), + variant_source_info, storage_conflicts: BitMatrix::new(0, 0), }; return Some(self.arena.alloc(proxy_layout));