mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +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
|
// 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.
|
// this name to identify what is being awaited by a suspended async functions.
|
||||||
let awaitee_ident = Ident::with_dummy_span(sym::__awaitee);
|
let awaitee_ident = Ident::with_dummy_span(sym::__awaitee);
|
||||||
let (awaitee_pat, awaitee_pat_hid) =
|
let (awaitee_pat, awaitee_pat_hid) = self.pat_ident_binding_mode(
|
||||||
self.pat_ident_binding_mode(span, awaitee_ident, hir::BindingAnnotation::MUT);
|
gen_future_span,
|
||||||
|
awaitee_ident,
|
||||||
|
hir::BindingAnnotation::MUT,
|
||||||
|
);
|
||||||
|
|
||||||
let task_context_ident = Ident::with_dummy_span(sym::_task_context);
|
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 tag_layout = cx.tcx.mk_layout(LayoutS::scalar(cx, tag));
|
||||||
|
|
||||||
let promoted_layouts = ineligible_locals
|
let promoted_layouts = ineligible_locals.iter().map(|local| {
|
||||||
.iter()
|
let field_ty = subst_field(info.field_tys[local].ty);
|
||||||
.map(|local| subst_field(info.field_tys[local].ty))
|
let uninit_ty = Ty::new_maybe_uninit(tcx, field_ty);
|
||||||
.map(|ty| Ty::new_maybe_uninit(tcx, ty))
|
Ok(cx.spanned_layout_of(uninit_ty, info.field_tys[local].source_info.span)?.layout)
|
||||||
.map(|ty| Ok(cx.layout_of(ty)?.layout));
|
});
|
||||||
let prefix_layouts = args
|
let prefix_layouts = args
|
||||||
.as_coroutine()
|
.as_coroutine()
|
||||||
.prefix_tys()
|
.prefix_tys()
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
Static,
|
Static,
|
||||||
),
|
),
|
||||||
source_info: SourceInfo {
|
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],
|
scope: scope[0],
|
||||||
},
|
},
|
||||||
ignore_for_traits: false,
|
ignore_for_traits: false,
|
||||||
@ -32,7 +32,7 @@
|
|||||||
Static,
|
Static,
|
||||||
),
|
),
|
||||||
source_info: SourceInfo {
|
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],
|
scope: scope[0],
|
||||||
},
|
},
|
||||||
ignore_for_traits: false,
|
ignore_for_traits: false,
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
// edition: 2021
|
// edition: 2021
|
||||||
// build-fail
|
// build-fail
|
||||||
//~^^ ERROR cycle detected when computing layout of
|
|
||||||
|
|
||||||
#![feature(impl_trait_in_assoc_type)]
|
#![feature(impl_trait_in_assoc_type)]
|
||||||
|
|
||||||
@ -21,6 +20,7 @@ impl Recur for () {
|
|||||||
|
|
||||||
fn recur(self) -> Self::Recur {
|
fn recur(self) -> Self::Recur {
|
||||||
async move { recur(self).await; }
|
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}>`...
|
LL | async move { recur(self).await; }
|
||||||
= 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}`...
|
|
|
||||||
|
= 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<<() 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::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:23:9: 23: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:23:9: 23:42}`, completing the cycle
|
= 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:19:1: 19:18>::recur`
|
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:22:5
|
--> $DIR/indirect-recursion-issue-112047.rs:21:5
|
||||||
|
|
|
|
||||||
LL | fn recur(self) -> Self::Recur {
|
LL | fn recur(self) -> Self::Recur {
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
Loading…
Reference in New Issue
Block a user