mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
Compute layout with spans for better cycle errors in coroutines
This commit is contained in:
parent
2b603f95a4
commit
7994b5849c
@ -792,8 +792,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
// debuggers and debugger extensions expect it to be called `__awaitee`. They use
|
||||
// this name to identify what is being awaited by a suspended async functions.
|
||||
let awaitee_ident = Ident::with_dummy_span(sym::__awaitee);
|
||||
let (awaitee_pat, awaitee_pat_hid) =
|
||||
self.pat_ident_binding_mode(span, awaitee_ident, hir::BindingAnnotation::MUT);
|
||||
let (awaitee_pat, awaitee_pat_hid) = self.pat_ident_binding_mode(
|
||||
gen_future_span,
|
||||
awaitee_ident,
|
||||
hir::BindingAnnotation::MUT,
|
||||
);
|
||||
|
||||
let task_context_ident = Ident::with_dummy_span(sym::_task_context);
|
||||
|
||||
|
@ -740,11 +740,11 @@ fn coroutine_layout<'tcx>(
|
||||
};
|
||||
let tag_layout = cx.tcx.mk_layout(LayoutS::scalar(cx, tag));
|
||||
|
||||
let promoted_layouts = ineligible_locals
|
||||
.iter()
|
||||
.map(|local| subst_field(info.field_tys[local].ty))
|
||||
.map(|ty| Ty::new_maybe_uninit(tcx, ty))
|
||||
.map(|ty| Ok(cx.layout_of(ty)?.layout));
|
||||
let promoted_layouts = ineligible_locals.iter().map(|local| {
|
||||
let field_ty = subst_field(info.field_tys[local].ty);
|
||||
let uninit_ty = Ty::new_maybe_uninit(tcx, field_ty);
|
||||
Ok(cx.spanned_layout_of(uninit_ty, info.field_tys[local].source_info.span)?.layout)
|
||||
});
|
||||
let prefix_layouts = args
|
||||
.as_coroutine()
|
||||
.prefix_tys()
|
||||
|
@ -14,7 +14,7 @@
|
||||
Static,
|
||||
),
|
||||
source_info: SourceInfo {
|
||||
span: $DIR/async_await.rs:16:9: 16:14 (#8),
|
||||
span: $DIR/async_await.rs:16:5: 16:14 (#9),
|
||||
scope: scope[0],
|
||||
},
|
||||
ignore_for_traits: false,
|
||||
@ -32,7 +32,7 @@
|
||||
Static,
|
||||
),
|
||||
source_info: SourceInfo {
|
||||
span: $DIR/async_await.rs:17:9: 17:14 (#10),
|
||||
span: $DIR/async_await.rs:17:5: 17:14 (#11),
|
||||
scope: scope[0],
|
||||
},
|
||||
ignore_for_traits: false,
|
||||
|
@ -1,6 +1,5 @@
|
||||
// edition: 2021
|
||||
// build-fail
|
||||
//~^^ ERROR cycle detected when computing layout of
|
||||
|
||||
#![feature(impl_trait_in_assoc_type)]
|
||||
|
||||
@ -21,6 +20,7 @@ impl Recur for () {
|
||||
|
||||
fn recur(self) -> Self::Recur {
|
||||
async move { recur(self).await; }
|
||||
//~^ ERROR cycle detected when computing layout of
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,14 +1,22 @@
|
||||
error[E0391]: cycle detected when computing layout of `{async block@$DIR/indirect-recursion-issue-112047.rs:23:9: 23:42}`
|
||||
error[E0391]: cycle detected when computing layout of `{async block@$DIR/indirect-recursion-issue-112047.rs:22:9: 22:42}`
|
||||
--> $DIR/indirect-recursion-issue-112047.rs:22:22
|
||||
|
|
||||
= note: ...which requires computing layout of `core::mem::maybe_uninit::MaybeUninit<{async fn body@$DIR/indirect-recursion-issue-112047.rs:15:31: 17:2}>`...
|
||||
= note: ...which requires computing layout of `core::mem::manually_drop::ManuallyDrop<{async fn body@$DIR/indirect-recursion-issue-112047.rs:15:31: 17:2}>`...
|
||||
= note: ...which requires computing layout of `{async fn body@$DIR/indirect-recursion-issue-112047.rs:15:31: 17:2}`...
|
||||
LL | async move { recur(self).await; }
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: ...which requires computing layout of `core::mem::maybe_uninit::MaybeUninit<{async fn body@$DIR/indirect-recursion-issue-112047.rs:14:31: 16:2}>`...
|
||||
= note: ...which requires computing layout of `core::mem::manually_drop::ManuallyDrop<{async fn body@$DIR/indirect-recursion-issue-112047.rs:14:31: 16:2}>`...
|
||||
note: ...which requires computing layout of `{async fn body@$DIR/indirect-recursion-issue-112047.rs:14:31: 16:2}`...
|
||||
--> $DIR/indirect-recursion-issue-112047.rs:15:5
|
||||
|
|
||||
LL | t.recur().await;
|
||||
| ^^^^^^^^^^^^^^^
|
||||
= note: ...which requires computing layout of `core::mem::maybe_uninit::MaybeUninit<<() as Recur>::Recur>`...
|
||||
= note: ...which requires computing layout of `core::mem::maybe_uninit::MaybeUninit<{async block@$DIR/indirect-recursion-issue-112047.rs:23:9: 23:42}>`...
|
||||
= note: ...which requires computing layout of `core::mem::manually_drop::ManuallyDrop<{async block@$DIR/indirect-recursion-issue-112047.rs:23:9: 23:42}>`...
|
||||
= note: ...which again requires computing layout of `{async block@$DIR/indirect-recursion-issue-112047.rs:23:9: 23:42}`, completing the cycle
|
||||
note: cycle used when elaborating drops for `<impl at $DIR/indirect-recursion-issue-112047.rs:19:1: 19:18>::recur`
|
||||
--> $DIR/indirect-recursion-issue-112047.rs:22:5
|
||||
= note: ...which requires computing layout of `core::mem::maybe_uninit::MaybeUninit<{async block@$DIR/indirect-recursion-issue-112047.rs:22:9: 22:42}>`...
|
||||
= note: ...which requires computing layout of `core::mem::manually_drop::ManuallyDrop<{async block@$DIR/indirect-recursion-issue-112047.rs:22:9: 22:42}>`...
|
||||
= note: ...which again requires computing layout of `{async block@$DIR/indirect-recursion-issue-112047.rs:22:9: 22:42}`, completing the cycle
|
||||
note: cycle used when elaborating drops for `<impl at $DIR/indirect-recursion-issue-112047.rs:18:1: 18:18>::recur`
|
||||
--> $DIR/indirect-recursion-issue-112047.rs:21:5
|
||||
|
|
||||
LL | fn recur(self) -> Self::Recur {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
Loading…
Reference in New Issue
Block a user