Skip to content

Commit 00739bd

Browse files
Compute layout with spans for better cycle errors in coroutines
1 parent eda8200 commit 00739bd

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -792,8 +792,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
792792
// debuggers and debugger extensions expect it to be called `__awaitee`. They use
793793
// this name to identify what is being awaited by a suspended async functions.
794794
let awaitee_ident = Ident::with_dummy_span(sym::__awaitee);
795-
let (awaitee_pat, awaitee_pat_hid) =
796-
self.pat_ident_binding_mode(span, awaitee_ident, hir::BindingAnnotation::MUT);
795+
let (awaitee_pat, awaitee_pat_hid) = self.pat_ident_binding_mode(
796+
gen_future_span,
797+
awaitee_ident,
798+
hir::BindingAnnotation::MUT,
799+
);
797800

798801
let task_context_ident = Ident::with_dummy_span(sym::_task_context);
799802

compiler/rustc_ty_utils/src/layout.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -740,11 +740,11 @@ fn coroutine_layout<'tcx>(
740740
};
741741
let tag_layout = cx.tcx.mk_layout(LayoutS::scalar(cx, tag));
742742

743-
let promoted_layouts = ineligible_locals
744-
.iter()
745-
.map(|local| subst_field(info.field_tys[local].ty))
746-
.map(|ty| Ty::new_maybe_uninit(tcx, ty))
747-
.map(|ty| Ok(cx.layout_of(ty)?.layout));
743+
let promoted_layouts = ineligible_locals.iter().map(|local| {
744+
let field_ty = subst_field(info.field_tys[local].ty);
745+
let uninit_ty = Ty::new_maybe_uninit(tcx, field_ty);
746+
Ok(cx.spanned_layout_of(uninit_ty, info.field_tys[local].source_info.span)?.layout)
747+
});
748748
let prefix_layouts = args
749749
.as_coroutine()
750750
.prefix_tys()

0 commit comments

Comments
 (0)