Async drop source info fix for proxy-drop-coroutine - fixes crash at debug info generation

This commit is contained in:
Andrew Zhogin 2025-05-04 01:24:39 +07:00
parent 097cd98869
commit a82b7a63b7

View file

@ -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<VariantIdx, IndexVec<FieldIdx, CoroutineSavedLocal>> =
iter::repeat(IndexVec::new()).take(CoroutineArgs::RESERVED_VARIANTS).collect();
let variant_source_info: IndexVec<VariantIdx, SourceInfo> =
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));